Commit 7d5b86ec authored by Rick Waldron's avatar Rick Waldron

Refactor defaultDisplay's node creation and display logic, -6

parent 2eda329b
...@@ -443,17 +443,13 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -443,17 +443,13 @@ function getWidthOrHeight( elem, name, extra ) {
) + "px"; ) + "px";
} }
// Try to determine the default display value of an element // Try to determine the default display value of an element
function css_defaultDisplay( nodeName ) { function css_defaultDisplay( nodeName ) {
var elem, var doc = document,
doc = document,
display = elemdisplay[ nodeName ]; display = elemdisplay[ nodeName ];
if ( !display ) { if ( !display ) {
elem = jQuery( doc.createElement( nodeName ) ); display = actualDisplay( nodeName, doc );
display = curCSS( elem.appendTo( doc.body )[0], "display" );
elem.remove();
// If the simple way fails, read from inside an iframe // If the simple way fails, read from inside an iframe
if ( display === "none" || !display ) { if ( display === "none" || !display ) {
...@@ -468,9 +464,7 @@ function css_defaultDisplay( nodeName ) { ...@@ -468,9 +464,7 @@ function css_defaultDisplay( nodeName ) {
doc.write("<!doctype html><html><body>"); doc.write("<!doctype html><html><body>");
doc.close(); doc.close();
elem = jQuery( doc.createElement( nodeName ) ); display = actualDisplay( nodeName, doc );
display = curCSS( elem.appendTo( doc.body )[0], "display" );
elem.remove();
iframe.detach(); iframe.detach();
} }
...@@ -481,6 +475,15 @@ function css_defaultDisplay( nodeName ) { ...@@ -481,6 +475,15 @@ function css_defaultDisplay( nodeName ) {
return display; 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.each([ "height", "width" ], function( i, name ) {
jQuery.cssHooks[ name ] = { jQuery.cssHooks[ name ] = {
get: function( elem, computed, extra ) { get: function( elem, computed, extra ) {
...@@ -541,7 +544,7 @@ if ( !jQuery.support.opacity ) { ...@@ -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 setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
// if value === "", then remove inline opacity #12685 // if value === "", then remove inline opacity #12685
if ( ( value >= 1 || value === "" ) && if ( ( value >= 1 || value === "" ) &&
jQuery.trim( filter.replace( ralpha, "" ) ) === "" && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
style.removeAttribute ) { style.removeAttribute ) {
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment