Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow destroying an editor when it failed to render properly #363

Merged
merged 1 commit into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/js/renderers/editor-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ let destroyHooks = {
// FIXME before we render marker, should delete previous renderNode's element
// and up until the next marker element

// If an atom throws during render we may end up later destroying a renderNode
// that has not rendered yet, so exit early here if so.
if (!renderNode.isRendered) {
return;
}
let { markupElement } = renderNode;

if (marker.section) {
Expand Down
6 changes: 1 addition & 5 deletions tests/unit/editor/atom-lifecycle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ module('Unit: Editor: Atom Lifecycle', {
},
afterEach() {
if (editor) {
try {
editor.destroy();
} catch(e) {}
editor.destroy();
editor = null;
}
}
Expand Down Expand Up @@ -207,8 +205,6 @@ test('rendering unknown atom without unknownAtomHandler throws', (assert) => {
}, new RegExp(`Unknown atom "${atomName}".*no unknownAtomHandler`));
});



test('onTeardown hook is called when editor is destroyed', (assert) => {
const atomName = 'test-atom';

Expand Down