Skip to content

Commit

Permalink
Merge pull request #363 from bustlelabs/allow-destroy-editor
Browse files Browse the repository at this point in the history
Allow destroying an editor when it failed to render properly
  • Loading branch information
bantic committed Apr 19, 2016
2 parents 242a4f5 + e16e0d6 commit 8f08f43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
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

0 comments on commit 8f08f43

Please sign in to comment.