aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwldrn <waldron.rick@gmail.com>2011-04-12 17:27:45 -0400
committerrwldrn <waldron.rick@gmail.com>2011-04-12 18:57:14 -0400
commit81de96af740f8d397585d8a6fc2a3765dfd16d49 (patch)
treea5bdcec533087a294dd235915d9fe1a89a25f244
parent885b64d4e683bce475a4ec8495cbba80b6b2e1b3 (diff)
downloadjquery-81de96af740f8d397585d8a6fc2a3765dfd16d49.tar.gz
jquery-81de96af740f8d397585d8a6fc2a3765dfd16d49.zip
Fixes #8099 using iframe to capture an element's real default display; suggested by lrbabe/louisremi
-rw-r--r--src/effects.js37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/effects.js b/src/effects.js
index e7987d210..bdd0715ef 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -548,35 +548,24 @@ if ( jQuery.expr && jQuery.expr.filters ) {
}
function defaultDisplay( nodeName ) {
- var iframe, iframeDoc, iframeNode, display;
if ( !elemdisplay[ nodeName ] ) {
- iframe = defaultDisplay.iframe.clone()[ 0 ];
+ var iframe, iframeDoc, iframeNode, display, elem;
- iframe.style.display = "none";
+ iframe = defaultDisplay.iframe.clone()[ 0 ];
document.body.appendChild( iframe );
- iframeDoc = iframe.contentWindow && iframe.contentWindow ||
- iframe.contentDocument.document && iframe.contentDocument.document ||
- iframe.contentDocument;
+ iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
- iframeNode = jQuery( "<" + nodeName + ">" ).appendTo( jQuery( "body", iframeDoc.document ) );
+ iframeDoc.open();
+ iframeDoc.write("<!doctype><html><body></body></html>");
+ elem = iframeDoc.createElement( nodeName );
+ iframeDoc.body.appendChild( elem );
+ iframeDoc.close();
- if ( !iframeNode.length ) {
- // this will only occur in IE
- iframeDoc.document.open();
- iframeDoc.document.write("<!doctype html><html><body></body></html>");
- elem = iframeDoc.document.createElement( nodeName );
- iframeDoc.document.body.appendChild( elem );
- iframeDoc.document.close();
-
- iframeNode = jQuery( elem );
- }
-
- // firefox returns undefined from css("display")
- display = iframeNode.css("display") || iframeNode[ 0 ].style.display;
+ display = jQuery( elem ).css( "display" );
if ( display === "none" || display === "" ) {
display = "block";
@@ -591,6 +580,12 @@ function defaultDisplay( nodeName ) {
return elemdisplay[ nodeName ];
}
-defaultDisplay.iframe = jQuery("<iframe/>");
+defaultDisplay.iframe = jQuery("<iframe/>", {
+ css: {
+ width: 0,
+ height: 0,
+ border: 0
+ }
+});
})( jQuery );