Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch '8099' of https://github.com/rwldrn/jquery. Fixes #8099.

Conflicts:
	test/data/testsuite.css
  • Loading branch information...
commit 1dda994c463f01977c7126407998d61efed218a5 2 parents 84712bd + a76decc
John Resig authored April 14, 2011
40  src/effects.js
... ...
@@ -1,6 +1,8 @@
1 1
 (function( jQuery ) {
2 2
 
3 3
 var elemdisplay = {},
  4
+	iframe = null, 
  5
+	iframeDoc = null,
4 6
 	rfxtypes = /^(?:toggle|show|hide)$/,
5 7
 	rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
6 8
 	timerId,
@@ -548,20 +550,52 @@ if ( jQuery.expr && jQuery.expr.filters ) {
548 550
 }
549 551
 
550 552
 function defaultDisplay( nodeName ) {
  553
+
551 554
 	if ( !elemdisplay[ nodeName ] ) {
552  
-		var elem = jQuery("<" + nodeName + ">").appendTo("body"),
553  
-			display = elem.css("display");
  555
+
  556
+		var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ),
  557
+			display = elem.css( "display" );
554 558
 
555 559
 		elem.remove();
556 560
 
557 561
 		if ( display === "none" || display === "" ) {
558  
-			display = "block";
  562
+
  563
+			// Get element's real default display by attaching it to a temp iframe
  564
+			// Conritbutions from Louis Remi and Julian Aurbourg
  565
+			// based on recommendation by Louis Remi
  566
+			
  567
+			// No iframe to use yet, so create it
  568
+			if ( !iframe ) {
  569
+				iframe = document.createElement( "iframe" );
  570
+				iframe.frameBorder = iframe.width = iframe.height = 0;
  571
+			}
  572
+
  573
+			document.body.appendChild( iframe );
  574
+
  575
+			// Create a cacheable copy of the iframe document on first call.
  576
+			// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
  577
+			// document to it, Webkit & Firefox won't allow reusing the iframe document
  578
+			if ( !iframeDoc || !iframe.createElement ) {
  579
+				iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
  580
+				iframeDoc.write( "<!doctype><html><body></body></html>" );
  581
+			}
  582
+
  583
+			elem = iframeDoc.createElement( nodeName );
  584
+
  585
+			iframeDoc.body.appendChild( elem );
  586
+
  587
+			display = jQuery.css( elem, "display" );
  588
+
  589
+			document.body.removeChild( iframe );
559 590
 		}
560 591
 
  592
+		// Store the correct default display
561 593
 		elemdisplay[ nodeName ] = display;
562 594
 	}
563 595
 
564 596
 	return elemdisplay[ nodeName ];
565 597
 }
566 598
 
  599
+
  600
+
567 601
 })( jQuery );
7  test/data/testsuite.css
@@ -111,4 +111,9 @@ div#show-tests * { display: none; }
111 111
 #nothiddendivchild.prct { font-size: 150%; }
112 112
 
113 113
 /* For testing type on vml in IE #7071 */
114  
-v\:oval { behavior:url(#default#VML); display:inline-block; }
  114
+v\:oval { behavior:url(#default#VML); display:inline-block; }
  115
+
  116
+/* 8099 changes to default styles are read correctly */
  117
+tt { display: none; }
  118
+sup { display: none; }
  119
+dfn { display: none; }
22  test/unit/effects.js
@@ -162,6 +162,28 @@ test("Persist correct display value", function() {
162 162
 	});
163 163
 });
164 164
 
  165
+test("show() resolves correct default display #8099", function() {
  166
+	expect(7);
  167
+	var tt8099 = jQuery("<tt/>").appendTo("body"), 
  168
+			dfn8099 = jQuery("<dfn/>", { html: "foo"}).appendTo("body");
  169
+
  170
+	equals( tt8099.css("display"), "none", "default display override for all tt" );
  171
+	equals( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" );
  172
+
  173
+	equals( jQuery("#foo").hide().show().css("display"), "block", "Correctly resolves display:block after hide/show" );
  174
+
  175
+	equals( tt8099.hide().css("display"), "none", "default display override for all tt" );
  176
+	equals( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" );
  177
+
  178
+	equals( dfn8099.css("display"), "none", "default display override for all dfn" );
  179
+	equals( dfn8099.show().css("display"), "inline", "Correctly resolves display:inline" );
  180
+
  181
+	tt8099.remove();
  182
+	dfn8099.remove();
  183
+
  184
+});
  185
+
  186
+
165 187
 test("animate(Hash, Object, Function)", function() {
166 188
 	expect(1);
167 189
 	stop();

0 notes on commit 1dda994

Please sign in to comment.
Something went wrong with that request. Please try again.