diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2012-12-10 10:05:39 -0500 |
---|---|---|
committer | Rick Waldron <waldron.rick@gmail.com> | 2012-12-10 10:05:39 -0500 |
commit | 7d5b86ec39eed3361a48b9a90627af22f9f25e1e (patch) | |
tree | 77d2d05617e7cf50999754463487b26c0b0ade2b /src/css.js | |
parent | 2eda329be6ac2f68e9b313ee607ea24165c68755 (diff) | |
download | jquery-7d5b86ec39eed3361a48b9a90627af22f9f25e1e.tar.gz jquery-7d5b86ec39eed3361a48b9a90627af22f9f25e1e.zip |
Refactor defaultDisplay's node creation and display logic, -6
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 23 |
1 files 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("<!doctype html><html><body>"); 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 |