Skip to content

Commit dd667b3

Browse files
author
Janusz Nykiel
committed
Clear sandbox console by replacing the whole div
Even with the original fix for marijnh#66, the sandbox didn't work for me on macOS 10.12.4. On a hunch (the problem appeared only after clearing the non-empty output once, so...), I've tried different methods of clearing the output, found on StackOverflow (hey, I'm learning! Great book BTW) instead of trying to nudge the output to reappear as in the original fix. This seems to work for me, at least with the latest browsers on macOS and Windows 10.
1 parent 78a4397 commit dd667b3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

html/js/sandbox.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,12 @@
290290
this.div = div;
291291
};
292292

293-
var safari = /Safari\//.test(navigator.userAgent);
294-
295293
Output.prototype = {
296-
clear: function() { this.div.innerHTML = ""; },
294+
clear: function() {
295+
var clone = this.div.cloneNode(false);
296+
this.div.parentNode.replaceChild(clone, this.div);
297+
this.div = clone;
298+
},
297299
out: function(type, args) {
298300
var wrap = document.createElement("pre");
299301
wrap.className = "sandbox-output-" + type;
@@ -306,8 +308,6 @@
306308
wrap.appendChild(represent(arg, 58));
307309
}
308310
this.div.appendChild(wrap);
309-
if (safari)
310-
setTimeout(function() { this.div.style.minHeight = ".1em"; }.bind(this), 50);
311311
}
312312
};
313313

0 commit comments

Comments
 (0)