From f934cc57a2e06f75e2cd076c1fdcdb24cc0f44d7 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 8 Feb 2015 11:07:04 +0100 Subject: [PATCH] Using MutationObserver for supported browsers --- wcfsetup/install/files/js/WCF.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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; }, -- 2.20.1