diff options
Diffstat (limited to 'src')
-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 |