diff --git a/src/definitions/modules/popup.js b/src/definitions/modules/popup.js index a3139ce1c..cce8f97bd 100644 --- a/src/definitions/modules/popup.js +++ b/src/definitions/modules/popup.js @@ -73,7 +73,7 @@ $.fn.popup = function(parameters) { element = this, instance = $module.data(moduleNamespace), - contextObserver, + documentObserver, elementNamespace, id, module @@ -103,12 +103,12 @@ $.fn.popup = function(parameters) { observeChanges: function() { if('MutationObserver' in window) { - contextObserver = new MutationObserver(module.event.contextChanged); - contextObserver.observe($context[0], { + documentObserver = new MutationObserver(module.event.documentChanged); + documentObserver.observe(document, { childList : true, subtree : true }); - module.debug('Setting up mutation observer', contextObserver); + module.debug('Setting up mutation observer', documentObserver); } }, @@ -158,8 +158,8 @@ $.fn.popup = function(parameters) { destroy: function() { module.debug('Destroying previous module'); - if(contextObserver) { - contextObserver.disconnect(); + if(documentObserver) { + documentObserver.disconnect(); } // remove element only if was created dynamically if($popup && !settings.preserve) { @@ -206,7 +206,7 @@ $.fn.popup = function(parameters) { module.set.position(); } }, - contextChanged: function(mutations) { + documentChanged: function(mutations) { [].forEach.call(mutations, function(mutation) { if(mutation.removedNodes) { [].forEach.call(mutation.removedNodes, function(node) { diff --git a/src/definitions/modules/sticky.js b/src/definitions/modules/sticky.js index a764299f9..761df1339 100644 --- a/src/definitions/modules/sticky.js +++ b/src/definitions/modules/sticky.js @@ -65,7 +65,7 @@ $.fn.sticky = function(parameters) { element = this, - contextObserver, + documentObserver, observer, module ; @@ -99,8 +99,8 @@ $.fn.sticky = function(parameters) { destroy: function() { module.verbose('Destroying previous instance'); module.reset(); - if(contextObserver) { - contextObserver.disconnect(); + if(documentObserver) { + documentObserver.disconnect(); } if(observer) { observer.disconnect(); @@ -116,13 +116,10 @@ $.fn.sticky = function(parameters) { }, observeChanges: function() { - var - context = $context[0] - ; if('MutationObserver' in window) { - contextObserver = new MutationObserver(module.event.contextChanged); - observer = new MutationObserver(module.event.changed); - contextObserver.observe($context[0], { + documentObserver = new MutationObserver(module.event.documentChanged); + observer = new MutationObserver(module.event.changed); + documentObserver.observe(document, { childList : true, subtree : true }); @@ -130,7 +127,7 @@ $.fn.sticky = function(parameters) { childList : true, subtree : true }); - observer.observe(context, { + observer.observe($context[0], { childList : true, subtree : true }); @@ -189,7 +186,7 @@ $.fn.sticky = function(parameters) { module.refresh(); }, 100); }, - contextChanged: function(mutations) { + documentChanged: function(mutations) { [].forEach.call(mutations, function(mutation) { if(mutation.removedNodes) { [].forEach.call(mutation.removedNodes, function(node) {