Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
[popup] Avoid infinite recursion by detach()ing the payload from the …
Browse files Browse the repository at this point in the history
…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
Gabriel Schulhof committed Nov 2, 2012
1 parent 4895716 commit 8199f24
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions js/widgets/popup.js
Expand Up @@ -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();
Expand Down

0 comments on commit 8199f24

Please sign in to comment.