Skip to content

Commit 2766b2b

Browse files
juliandescottesjasonLaster
authored andcommitted
unlink codemirror doc on component unmount (firefox-devtools#2129)
1 parent cb4fa1f commit 2766b2b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/components/Editor/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ const Editor = React.createClass({
201201
resizeBreakpointGutter(codeMirror);
202202
debugGlobal("cm", codeMirror);
203203

204-
if (this.props.sourceText) {
204+
if (this.props.selectedSource) {
205+
let sourceId = this.props.selectedSource.get("id");
206+
this.editor.replaceDocument(getDocument(sourceId));
207+
} else if (this.props.sourceText) {
205208
this.setText(this.props.sourceText.get("text"));
206209
}
207210
},

src/utils/editor/source-editor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ class SourceEditor {
4949
}
5050

5151
destroy() {
52-
// No need to do anything.
52+
// Unlink the current document.
53+
if (this.editor.doc) {
54+
this.editor.doc.cm = null;
55+
}
5356
}
5457

5558
get codeMirror(): any {

0 commit comments

Comments
 (0)