0
Fork 0
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:
Austin Burdine 2017-02-17 04:15:28 -06:00 committed by Kevin Ansfield
parent aff121ebce
commit 2d6bb65322

View file

@ -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;
}
}
});