mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐛 don't destroy codemirror editor if it doesn't exist (#530)
closes TryGhost/Ghost#7855 - check if codemirror has been initialized before trying to destroy it
This commit is contained in:
parent
aff121ebce
commit
2d6bb65322
1 changed files with 8 additions and 3 deletions
|
@ -55,9 +55,14 @@ const CmEditorComponent = Component.extend(InvokeActionMixin, {
|
|||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
let editor = this._editor.getWrapperElement();
|
||||
editor.parentNode.removeChild(editor);
|
||||
this._editor = null;
|
||||
// Ensure the editor exists before trying to destroy it. This fixes
|
||||
// an error that occurs if codemirror hasn't finished loading before
|
||||
// the component is destroyed.
|
||||
if (this._editor) {
|
||||
let editor = this._editor.getWrapperElement();
|
||||
editor.parentNode.removeChild(editor);
|
||||
this._editor = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue