diff options
author | Brant Burnett <btburnett3@gmail.com> | 2010-02-17 16:22:19 +0000 |
---|---|---|
committer | Brant Burnett <btburnett3@gmail.com> | 2010-02-17 16:22:19 +0000 |
commit | 53ab4fb5de2c252686973d46eaba1bb2a34bceb8 (patch) | |
tree | de01a423433b5087a2d21df2e0e9ecdc1178e5b2 | |
parent | b9882e903ae1ccac83131a754e518eadcc6400be (diff) | |
download | jquery-ui-53ab4fb5de2c252686973d46eaba1bb2a34bceb8.tar.gz jquery-ui-53ab4fb5de2c252686973d46eaba1bb2a34bceb8.zip |
Dialog: Overlays are now cached for reuse with subsequent dialogs (Fixed #5185: .ui-widget-overlay CSS selector causes consistent large memory leak in IE)
-rw-r--r-- | ui/jquery.ui.dialog.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 53af64142..167ffaca7 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -592,6 +592,8 @@ $.extend($.ui.dialog, { $.extend($.ui.dialog.overlay, { instances: [], + // reuse old instances due to IE memory leak with alpha transparency (see #5185) + oldInstances: [], maxZ: 0, events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','), function(event) { return event + '.dialog-overlay'; }).join(' '), @@ -604,7 +606,7 @@ $.extend($.ui.dialog.overlay, { // handle $(el).dialog().dialog('close') (see #4065) if ($.ui.dialog.overlay.instances.length) { $(document).bind($.ui.dialog.overlay.events, function(event) { - // stop events if the z-index of the target is <= the z-index of the overlay + // stop events if the z-index of the target is < the z-index of the overlay return ($(event.target).zIndex() >= $.ui.dialog.overlay.maxZ); }); } @@ -620,11 +622,12 @@ $.extend($.ui.dialog.overlay, { $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize); } - var $el = $('<div></div>').appendTo(document.body) - .addClass('ui-widget-overlay').css({ - width: this.width(), - height: this.height() - }); + var $el = (this.oldInstances.length ? this.oldInstances.splice(0, 1)[0] : $('<div></div>').addClass('ui-widget-overlay')) + .appendTo(document.body) + .css({ + width: this.width(), + height: this.height() + }); ($.fn.bgiframe && $el.bgiframe()); @@ -633,7 +636,7 @@ $.extend($.ui.dialog.overlay, { }, destroy: function($el) { - this.instances.splice($.inArray(this.instances, $el), 1); + this.oldInstances.push(this.instances.splice($.inArray(this.instances, $el), 1)[0]); if (this.instances.length === 0) { $([document, window]).unbind('.dialog-overlay'); |