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,10 +55,15 @@ const CmEditorComponent = Component.extend(InvokeActionMixin, {
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
// 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();
|
let editor = this._editor.getWrapperElement();
|
||||||
editor.parentNode.removeChild(editor);
|
editor.parentNode.removeChild(editor);
|
||||||
this._editor = null;
|
this._editor = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CmEditorComponent.reopenClass({
|
CmEditorComponent.reopenClass({
|
||||||
|
|
Loading…
Add table
Reference in a new issue