Skip to content

Commit 5af6bb0

Browse files
committed
Don't set innerHTML in IE
It damages parent-child relationships in subnodes, which we might still need later.
1 parent db1b282 commit 5af6bb0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/codemirror.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,7 @@ window.CodeMirror = (function() {
550550
function patchDisplay(cm, from, to, intact, updateNumbersFrom) {
551551
var dims = getDimensions(cm);
552552
var display = cm.display, lineNumbers = cm.options.lineNumbers;
553-
// IE does bad things to nodes when .innerHTML = "" is used on a parent
554-
// we still need widgets and markers intact to add back to the new content later
555-
if (!intact.length && !ie && (!webkit || !cm.display.currentWheelTarget))
553+
if (!intact.length && (!webkit || !cm.display.currentWheelTarget))
556554
removeChildren(display.lineDiv);
557555
var container = display.lineDiv, cur = container.firstChild;
558556

@@ -1114,7 +1112,6 @@ window.CodeMirror = (function() {
11141112
}
11151113
removeChildrenAndAdd(display.measure, measureText);
11161114
var height = measureText.offsetHeight / 50;
1117-
display.measure.removeChild(measureText);
11181115
if (height > 3) display.cachedTextHeight = height;
11191116
removeChildren(display.measure);
11201117
return height || 1;
@@ -4354,7 +4351,9 @@ window.CodeMirror = (function() {
43544351
}
43554352

43564353
function removeChildren(e) {
4357-
e.innerHTML = "";
4354+
// IE will break all parent-child relations in subnodes when setting innerHTML
4355+
if (!ie) e.innerHTML = "";
4356+
else while (e.firstChild) e.removeChild(e.firstChild);
43584357
return e;
43594358
}
43604359

0 commit comments

Comments
 (0)