From: Alexander Ebert Date: Sun, 8 Feb 2015 10:07:04 +0000 (+0100) Subject: Using MutationObserver for supported browsers X-Git-Tag: 2.1.0_RC_1~58 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f934cc57a2e06f75e2cd076c1fdcdb24cc0f44d7;p=GitHub%2FWoltLab%2FWCF.git Using MutationObserver for supported browsers --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index a327938d5e..5d796ea34c 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -5951,7 +5951,29 @@ WCF.DOMNodeRemovedHandler = { _bindListener: function() { if (this._isListening) return; - $(document).bind('DOMNodeRemoved', $.proxy(this._executeCallbacks, this)); + if (window.MutationObserver) { + var $mutationObserver = new MutationObserver((function(mutations) { + var $triggerEvent = false; + + mutations.forEach((function(mutation) { + if (mutation.removedNodes.length) { + $triggerEvent = true; + } + }).bind(this)); + + if ($triggerEvent) { + this._executeCallbacks({ }); + } + }).bind(this)); + + $mutationObserver.observe(document.body, { + childList: true, + subtree: true + }); + } + else { + $(document).bind('DOMNodeRemoved', $.proxy(this._executeCallbacks, this)); + } this._isListening = true; },