Ticket #8099 Performance tweaking, credits

This commit is contained in:
rwldrn 2011-04-13 15:43:15 -04:00
parent 59240d31c0
commit a76decc476
3 changed files with 27 additions and 23 deletions

28
src/effects.js vendored
View file

@ -556,35 +556,37 @@ function defaultDisplay( nodeName ) {
var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ),
display = elem.css( "display" );
elem.remove();
elem.remove();
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
if ( !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.write("<!doctype><html><body></body></html>");
} else {
// Reuse previous iframe
document.body.appendChild( iframe );
iframeDoc.write( "<!doctype><html><body></body></html>" );
}
elem = iframeDoc.createElement( nodeName );
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