From 0a42dcdcb400d6fc275b04d6cb052a48efd68536 Mon Sep 17 00:00:00 2001 From: Euan Goddard Date: Fri, 21 Jun 2019 14:09:51 +0100 Subject: [PATCH 1/2] Tear down mutation observer on modal destruction Fixes #6832 --- src/definitions/modules/modal.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index d2793ee0a..cb125349c 100755 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -138,6 +138,9 @@ $.fn.modal = function(parameters) { }, destroy: function() { + if (module.observer) { + observer.disconnect(); + } module.verbose('Destroying previous modal'); $module .removeData(moduleNamespace) @@ -160,6 +163,7 @@ $.fn.modal = function(parameters) { subtree : true }); module.debug('Setting up mutation observer', observer); + module.observer = observer; } }, From 9b49d4935230f731c78ecaac53bcd34f52a3588b Mon Sep 17 00:00:00 2001 From: Euan Goddard Date: Mon, 24 Jun 2019 08:46:14 +0100 Subject: [PATCH 2/2] Used module level variable for observer Post-review changes --- src/definitions/modules/modal.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index cb125349c..915b2c29d 100755 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -138,7 +138,7 @@ $.fn.modal = function(parameters) { }, destroy: function() { - if (module.observer) { + if (observer) { observer.disconnect(); } module.verbose('Destroying previous modal'); @@ -163,7 +163,6 @@ $.fn.modal = function(parameters) { subtree : true }); module.debug('Setting up mutation observer', observer); - module.observer = observer; } },