Permalink
Browse files

[popup] Avoid infinite recursion by detach()ing the payload from the …

…container before attempting to put it back to its original place in the DOM (which may not exist, if the popup was created based on a detached element) -- Fixes #5244
  • Loading branch information...
gabrielschulhof committed Nov 2, 2012
1 parent 4895716 commit 8199f24235e72e9d1cf71c6adac39e48b6b6d2b5
Showing with 7 additions and 0 deletions.
  1. +7 −0 js/widgets/popup.js
View
@@ -683,6 +683,13 @@ define( [ "jquery",
// Put the element back to where the placeholder was and remove the "ui-popup" class
this._setTheme( "none" );
this.element
// Cannot directly insertAfter() - we need to detach() first, because
// insertAfter() will do nothing if the payload div was not attached
// to the DOM at the time the widget was created, and so the payload
// will remain inside the container even after we call insertAfter().
// If that happens and we remove the container a few lines below, we
// will cause an infinite recursion - #5244
.detach()
.insertAfter( this._ui.placeholder )
.removeClass( "ui-popup ui-overlay-shadow ui-corner-all" );
this._ui.screen.remove();

0 comments on commit 8199f24

Please sign in to comment.