Skip to content

Commit

Permalink
Merge pull request #297 from mikelkew/mutation-observer
Browse files Browse the repository at this point in the history
Use MutationObserver instead of Mutation Events
  • Loading branch information
gsamokovarov committed Aug 19, 2020
2 parents 28dfbc4 + ace938e commit 008e6c6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/web_console/templates/console.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ REPLConsole.prototype.install = function(container) {
}
}

var observer = new MutationObserver(function(mutationsList) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
shiftConsoleActions();
}
}
});

// Initialize
this.container = container;
this.outer = consoleOuter;
Expand All @@ -429,7 +437,7 @@ REPLConsole.prototype.install = function(container) {

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

REPLConsole.currentSession = this;
};
Expand Down

0 comments on commit 008e6c6

Please sign in to comment.