diff options
author | rwldrn <waldron.rick@gmail.com> | 2011-04-13 15:43:15 -0400 |
---|---|---|
committer | rwldrn <waldron.rick@gmail.com> | 2011-04-13 15:43:15 -0400 |
commit | a76decc47660591bb807aecf56825019da8b39fa (patch) | |
tree | 4a18d1d71ff0a4ae074481b6041ace6b28a15e0e /src/effects.js | |
parent | 59240d31c0c277a60fdc187e0fc9884007971106 (diff) | |
download | jquery-a76decc47660591bb807aecf56825019da8b39fa.tar.gz jquery-a76decc47660591bb807aecf56825019da8b39fa.zip |
Ticket #8099 Performance tweaking, credits
Diffstat (limited to 'src/effects.js')
-rw-r--r-- | src/effects.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/effects.js b/src/effects.js index 460811cd9..a43d5cb3c 100644 --- a/src/effects.js +++ b/src/effects.js @@ -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 |