Skip to content

Commit

Permalink
Guard against setting on destroyed object
Browse files Browse the repository at this point in the history
  • Loading branch information
wenincode authored and chris-hut committed Oct 16, 2023
1 parent 838a8a9 commit 4882490
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions ui/packages/consul-ui/app/components/code-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,24 @@ export default Component.extend({
}
},
setMode: function (mode) {
let options = {
...DEFAULTS,
mode: mode.mime,
readOnly: this.readonly,
};
if (mode.name === 'XML') {
options.htmlMode = mode.htmlMode;
options.matchClosing = mode.matchClosing;
options.alignCDATA = mode.alignCDATA;
}
set(this, 'options', options);
if (!this.isDestroying && !this.isDestroyed) {
let options = {
...DEFAULTS,
mode: mode.mime,
readOnly: this.readonly,
};
if (mode.name === 'XML') {
options.htmlMode = mode.htmlMode;
options.matchClosing = mode.matchClosing;
options.alignCDATA = mode.alignCDATA;
}
set(this, 'options', options);

const editor = this.editor;
editor.setOption('mode', mode.mime);
this.helper.lint(editor, mode.mode);
set(this, 'mode', mode);
const editor = this.editor;
editor.setOption('mode', mode.mime);
this.helper.lint(editor, mode.mode);
set(this, 'mode', mode);
}
},
willDestroyElement: function () {
this._super(...arguments);
Expand Down

0 comments on commit 4882490

Please sign in to comment.