From 7d5b86ec39eed3361a48b9a90627af22f9f25e1e Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Mon, 10 Dec 2012 10:05:39 -0500 Subject: [PATCH] Refactor defaultDisplay's node creation and display logic, -6 --- src/css.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/css.js b/src/css.js index c9a1ab433..5df4f7efd 100644 --- a/src/css.js +++ b/src/css.js @@ -443,17 +443,13 @@ function getWidthOrHeight( elem, name, extra ) { ) + "px"; } - // Try to determine the default display value of an element function css_defaultDisplay( nodeName ) { - var elem, - doc = document, + var doc = document, display = elemdisplay[ nodeName ]; if ( !display ) { - elem = jQuery( doc.createElement( nodeName ) ); - display = curCSS( elem.appendTo( doc.body )[0], "display" ); - elem.remove(); + display = actualDisplay( nodeName, doc ); // If the simple way fails, read from inside an iframe if ( display === "none" || !display ) { @@ -468,9 +464,7 @@ function css_defaultDisplay( nodeName ) { doc.write(""); doc.close(); - elem = jQuery( doc.createElement( nodeName ) ); - display = curCSS( elem.appendTo( doc.body )[0], "display" ); - elem.remove(); + display = actualDisplay( nodeName, doc ); iframe.detach(); } @@ -481,6 +475,15 @@ function css_defaultDisplay( nodeName ) { return display; } +// Called ONLY from within css_defaultDisplay +function actualDisplay( name, doc ) { + var elem, display; + elem = jQuery( doc.createElement( name ) ); + display = curCSS( elem.appendTo( doc.body )[0], "display" ); + elem.remove(); + return display; +} + jQuery.each([ "height", "width" ], function( i, name ) { jQuery.cssHooks[ name ] = { get: function( elem, computed, extra ) { @@ -541,7 +544,7 @@ if ( !jQuery.support.opacity ) { // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 // if value === "", then remove inline opacity #12685 if ( ( value >= 1 || value === "" ) && - jQuery.trim( filter.replace( ralpha, "" ) ) === "" && + jQuery.trim( filter.replace( ralpha, "" ) ) === "" && style.removeAttribute ) { // Setting style.filter to null, "" & " " still leave "filter:" in the cssText -- 2.39.5