Skip to content

Commit 008e6c6

Browse files
authored
Merge pull request #297 from mikelkew/mutation-observer
Use MutationObserver instead of Mutation Events
2 parents 28dfbc4 + ace938e commit 008e6c6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/web_console/templates/console.js.erb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,14 @@ REPLConsole.prototype.install = function(container) {
418418
}
419419
}
420420

421+
var observer = new MutationObserver(function(mutationsList) {
422+
for (let mutation of mutationsList) {
423+
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
424+
shiftConsoleActions();
425+
}
426+
}
427+
});
428+
421429
// Initialize
422430
this.container = container;
423431
this.outer = consoleOuter;
@@ -429,7 +437,7 @@ REPLConsole.prototype.install = function(container) {
429437

430438
findChild(container, 'resizer').addEventListener('mousedown', resizeContainer);
431439
findChild(consoleActions, 'close-button').addEventListener('click', closeContainer);
432-
consoleOuter.addEventListener('DOMNodeInserted', shiftConsoleActions);
440+
observer.observe(consoleOuter, { childList: true, subtree: true });
433441

434442
REPLConsole.currentSession = this;
435443
};

0 commit comments

Comments
 (0)