Skip to content
Permalink
Browse files

Landing pull request 352. Slightly improved defaultDisplay() and Thro…

…bber of Doom. Fixes #8994.

More Details:
 - #352
 - http://bugs.jquery.com/ticket/8994
  • Loading branch information...
mathiasbynens authored and timmywil committed May 20, 2011
1 parent f82b9dd commit b43910a496ccb2b44dcc11b64667e21521aa4994
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/effects.js
@@ -574,7 +574,8 @@ function defaultDisplay( nodeName ) {

if ( !elemdisplay[ nodeName ] ) {

var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ),
var body = document.body,
elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
display = elem.css( "display" );

elem.remove();
@@ -588,14 +589,15 @@ function defaultDisplay( nodeName ) {
iframe.frameBorder = iframe.width = iframe.height = 0;
}

document.body.appendChild( iframe );
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
// 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>" );
iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );

This comment has been minimized.

Copy link
@louisremi

louisremi May 20, 2011

Contributor

What's the benefit of not writing the doctype? Does it speeds anything up?

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens May 20, 2011

Author Contributor

Elements may have a different default display value in quirks mode vs. standards mode. See #352 (comment)

Note that your previous implementation was using <!doctype>, which doesn’t trigger standards mode.

This comment has been minimized.

Copy link
@jdalton

jdalton May 20, 2011

Member

Can someone explain the bug this comment is addressing:

// 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.
iframeDoc.close();
}

elem = iframeDoc.createElement( nodeName );
@@ -604,7 +606,7 @@ function defaultDisplay( nodeName ) {

display = jQuery.css( elem, "display" );

document.body.removeChild( iframe );
body.removeChild( iframe );
}

// Store the correct default display

0 comments on commit b43910a

Please sign in to comment.
You can’t perform that action at this time.