Commit 5c1725d6 authored by John Resig's avatar John Resig

Rewrote the hide and show methods to fix the issue with Safari not hiding...

Rewrote the hide and show methods to fix the issue with Safari not hiding distached elements. Fixed #1239, #2233, #3038, #3343, #3395. They're also faster now, as well.
parent 18ee5a93
var elemdisplay = {};
jQuery.fn.extend({ jQuery.fn.extend({
show: function(speed,callback){ show: function(speed,callback){
return speed ? if ( speed ) {
this.animate({ return this.animate({
height: "show", width: "show", opacity: "show" height: "show", width: "show", opacity: "show"
}, speed, callback) : }, speed, callback);
} else {
this.filter(":hidden").each(function(){ for ( var i = 0, l = this.length; i < l; i++ ){
this.style.display = this.oldblock || ""; var old = jQuery.data(this[i], "olddisplay");
if ( jQuery.css(this,"display") == "none" ) {
var elem = jQuery("<" + this.tagName + " />").appendTo("body"); this[i].style.display = old || "";
this.style.display = elem.css("display");
// handle an edge condition where css is - div { display:none; } or similar if ( jQuery.css(this[i], "display") === "none" ) {
if (this.style.display == "none") var tagName = this[i].tagName, display;
this.style.display = "block";
elem.remove(); if ( elemdisplay[ tagName ] ) {
display = elemdisplay[ tagName ];
} else {
var elem = jQuery("<" + this[i].tagName + " />").appendTo("body");
display = elem.css("display");
if ( display === "none" )
display = "block";
elem.remove();
elemdisplay[ this[i].tagName ] = display;
}
this[i].style.display = jQuery.data(this[i], "olddisplay", display);
} }
}).end(); }
return this;
}
}, },
hide: function(speed,callback){ hide: function(speed,callback){
return speed ? if ( speed ) {
this.animate({ return this.animate({
height: "hide", width: "hide", opacity: "hide" height: "hide", width: "hide", opacity: "hide"
}, speed, callback) : }, speed, callback);
} else {
this.filter(":visible").each(function(){ for ( var i = 0, l = this.length; i < l; i++ ){
this.oldblock = this.oldblock || jQuery.css(this,"display"); var old = jQuery.data(this[i], "olddisplay");
this.style.display = "none"; if ( !old && old !== "none" )
}).end(); jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
this[i].style.display = "none";
}
return this;
}
}, },
// Save the old toggle function // Save the old toggle function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment