MDL-67513 core: Only move modal to body if currently attached

A previous change as part of this commitset was intended to move the
modal to the document.body, but where the modal had been destroyed it
was instead added back to the body.
This commit is contained in:
Andrew Nicols
2020-11-16 09:37:48 +01:00
committed by Eloy Lafuente (stronk7)
parent d661fbfbc1
commit be2afb52c1
6 changed files with 12 additions and 8 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,2 +1,2 @@
define ("core/modal_backdrop",["jquery","core/templates","core/notification","core/fullscreen"],function(a,b,c,d){var e={ROOT:"[data-region=\"modal-backdrop\"]"},f=function(b){this.root=a(b);this.isAttached=!1;if(!this.root.is(e.ROOT)){c.exception({message:"Element is not a modal backdrop"})}};f.prototype.getRoot=function(){return this.root};f.prototype.getAttachmentPoint=function(){return a(d.getElement()||document.body)};f.prototype.attachToDOM=function(){this.getAttachmentPoint().append(this.root);if(this.isAttached){return}this.isAttached=!0};f.prototype.setZIndex=function(a){this.root.css("z-index",a)};f.prototype.isVisible=function(){return this.root.hasClass("show")};f.prototype.hasTransitions=function(){return this.getRoot().hasClass("fade")};f.prototype.show=function(){if(this.isVisible()){return}this.attachToDOM();this.root.removeClass("hide").addClass("show")};f.prototype.hide=function(){if(!this.isVisible()){return}if(this.hasTransitions()){this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",function(){this.getRoot().removeClass("show").addClass("hide")}.bind(this))}else{this.getRoot().removeClass("show").addClass("hide")}a(document.body).append(this.getRoot())};f.prototype.destroy=function(){this.root.remove()};return f});
define ("core/modal_backdrop",["jquery","core/templates","core/notification","core/fullscreen"],function(a,b,c,d){var e={ROOT:"[data-region=\"modal-backdrop\"]"},f=function(b){this.root=a(b);this.isAttached=!1;if(!this.root.is(e.ROOT)){c.exception({message:"Element is not a modal backdrop"})}};f.prototype.getRoot=function(){return this.root};f.prototype.getAttachmentPoint=function(){return a(d.getElement()||document.body)};f.prototype.attachToDOM=function(){this.getAttachmentPoint().append(this.root);if(this.isAttached){return}this.isAttached=!0};f.prototype.setZIndex=function(a){this.root.css("z-index",a)};f.prototype.isVisible=function(){return this.root.hasClass("show")};f.prototype.hasTransitions=function(){return this.getRoot().hasClass("fade")};f.prototype.show=function(){if(this.isVisible()){return}this.attachToDOM();this.root.removeClass("hide").addClass("show")};f.prototype.hide=function(){if(!this.isVisible()){return}if(this.hasTransitions()){this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",function(){this.getRoot().removeClass("show").addClass("hide")}.bind(this))}else{this.getRoot().removeClass("show").addClass("hide")}if(a(document.body).find(this.getRoot()).length){a(document.body).append(this.getRoot())}};f.prototype.destroy=function(){this.root.remove()};return f});
//# sourceMappingURL=modal_backdrop.min.js.map
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -735,8 +735,10 @@ define([
this.getRoot().removeClass('show').addClass('hide');
}
// Ensure the modal is moved onto the body node.
$(document.body).append(this.getRoot());
// Ensure the modal is moved onto the body node if it is still attached to the DOM.
if ($(document.body).find(this.getRoot()).length) {
$(document.body).append(this.getRoot());
}
this.root.trigger(ModalEvents.hidden, this);
}.bind(this));
+4 -2
View File
@@ -142,8 +142,10 @@ define(['jquery', 'core/templates', 'core/notification', 'core/fullscreen'],
this.getRoot().removeClass('show').addClass('hide');
}
// Ensure the modal is moved back onto the body node.
$(document.body).append(this.getRoot());
// Ensure the modal is moved onto the body node if it is still attached to the DOM.
if ($(document.body).find(this.getRoot()).length) {
$(document.body).append(this.getRoot());
}
};
/**