Ticket #8099 Performance tweaking, credits
This commit is contained in:
parent
59240d31c0
commit
a76decc476
24
src/effects.js
vendored
24
src/effects.js
vendored
|
@ -560,31 +560,33 @@ function defaultDisplay( nodeName ) {
|
||||||
|
|
||||||
if ( display === "none" || display === "" ) {
|
if ( display === "none" || display === "" ) {
|
||||||
|
|
||||||
|
// Get element's real default display by attaching it to a temp iframe
|
||||||
|
// Conritbutions from Louis Remi and Julian Aurbourg
|
||||||
|
// based on recommendation by Louis Remi
|
||||||
|
|
||||||
// No iframe to use yet, so create it
|
// No iframe to use yet, so create it
|
||||||
if ( !iframe ) {
|
if ( !iframe ) {
|
||||||
|
|
||||||
iframe = document.createElement( "iframe" );
|
iframe = document.createElement( "iframe" );
|
||||||
iframe.width = iframe.height = 0;
|
iframe.frameBorder = iframe.width = iframe.height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
document.body.appendChild( iframe );
|
document.body.appendChild( iframe );
|
||||||
|
|
||||||
|
// Create a cacheable copy of the iframe document on first call.
|
||||||
|
// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
|
||||||
|
// document to it, Webkit & Firefox won't allow reusing the iframe document
|
||||||
|
if ( !iframeDoc || !iframe.createElement ) {
|
||||||
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
|
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
|
||||||
iframeDoc.write("<!doctype><html><body></body></html>");
|
iframeDoc.write( "<!doctype><html><body></body></html>" );
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Reuse previous iframe
|
|
||||||
document.body.appendChild( iframe );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elem = iframeDoc.createElement( nodeName );
|
elem = iframeDoc.createElement( nodeName );
|
||||||
|
|
||||||
iframeDoc.body.appendChild( elem );
|
iframeDoc.body.appendChild( elem );
|
||||||
|
|
||||||
display = jQuery( elem ).css( "display" );
|
display = jQuery.css( elem, "display" );
|
||||||
|
|
||||||
iframe.parentNode.removeChild( iframe );
|
document.body.removeChild( iframe );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the correct default display
|
// Store the correct default display
|
||||||
|
|
|
@ -112,3 +112,5 @@ div#show-tests * { display: none; }
|
||||||
|
|
||||||
/* 8099 changes to default styles are read correctly */
|
/* 8099 changes to default styles are read correctly */
|
||||||
tt { display: none; }
|
tt { display: none; }
|
||||||
|
sup { display: none; }
|
||||||
|
dfn { display: none; }
|
||||||
|
|
20
test/unit/effects.js
vendored
20
test/unit/effects.js
vendored
|
@ -164,22 +164,22 @@ test("Persist correct display value", function() {
|
||||||
|
|
||||||
test("show() resolves correct default display #8099", function() {
|
test("show() resolves correct default display #8099", function() {
|
||||||
expect(7);
|
expect(7);
|
||||||
var bug8099 = jQuery("<tt/>").appendTo("#main"),
|
var tt8099 = jQuery("<tt/>").appendTo("body"),
|
||||||
div8099 = jQuery("<div/>", { className: "hidden" }).appendTo("#main");
|
dfn8099 = jQuery("<dfn/>", { html: "foo"}).appendTo("body");
|
||||||
|
|
||||||
equals( bug8099.css("display"), "none", "default display override for all tt" );
|
equals( tt8099.css("display"), "none", "default display override for all tt" );
|
||||||
equals( bug8099.show().css("display"), "inline", "Correctly resolves display:inline" );
|
equals( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" );
|
||||||
|
|
||||||
equals( jQuery("#foo").hide().show().css("display"), "block", "Correctly resolves display:block after hide/show" );
|
equals( jQuery("#foo").hide().show().css("display"), "block", "Correctly resolves display:block after hide/show" );
|
||||||
|
|
||||||
equals( bug8099.hide().css("display"), "none", "default display override for all tt" );
|
equals( tt8099.hide().css("display"), "none", "default display override for all tt" );
|
||||||
equals( bug8099.show().css("display"), "inline", "Correctly resolves display:inline" );
|
equals( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" );
|
||||||
|
|
||||||
equals( div8099.show().css("display"), "block", "default display override for all div.hidden" );
|
equals( dfn8099.css("display"), "none", "default display override for all dfn" );
|
||||||
equals( div8099.hide().css("display"), "none", "Correctly resolves display:none" );
|
equals( dfn8099.show().css("display"), "inline", "Correctly resolves display:inline" );
|
||||||
|
|
||||||
bug8099.remove();
|
tt8099.remove();
|
||||||
div8099.remove();
|
dfn8099.remove();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue