From eba774c86389f808c2d6ec54fa3179bb85b6328d Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 31 May 2016 10:19:07 +0200 Subject: [PATCH] Prevent DOM pollution when having many confirmation dialogs. Append confirmation dialog on show and detach it on hide. HFJ-1969 (cherry picked from commit 0a63d12) --- js/h5p-confirmation-dialog.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/h5p-confirmation-dialog.js b/js/h5p-confirmation-dialog.js index a8d4ac2..84c8827 100644 --- a/js/h5p-confirmation-dialog.js +++ b/js/h5p-confirmation-dialog.js @@ -141,14 +141,12 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { var wrapperElement; /** - * Append confirmation dialog + * Set parent of confirmation dialog * @param {HTMLElement} wrapper * @returns {H5P.ConfirmationDialog} */ this.appendTo = function (wrapper) { - wrapper.appendChild(popupBackground); wrapperElement = wrapper; - return this; }; @@ -182,6 +180,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { * @returns {H5P.ConfirmationDialog} */ this.show = function (offsetTop) { + wrapperElement.appendChild(popupBackground); popupBackground.classList.remove('hidden'); fitToContainer(offsetTop); setTimeout(function () { @@ -215,6 +214,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { popup.classList.add('hidden'); setTimeout(function () { popupBackground.classList.add('hidden'); + wrapperElement.removeChild(popupBackground); }, 100); return this;