diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2012-08-29 08:50:56 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-08-29 12:34:12 -0400 |
commit | 670e3ff040b0a7164f36a3c5e07214420b8b09f4 (patch) | |
tree | e647ec42a4874f9bd744cd07a45b188fa973d33a /src/css.js | |
parent | be2899b3b1dfcd75516bbcf12c4eb49af9073538 (diff) | |
download | jquery-670e3ff040b0a7164f36a3c5e07214420b8b09f4.tar.gz jquery-670e3ff040b0a7164f36a3c5e07214420b8b09f4.zip |
Fix #12243, $("col").width() should return the column's width. Close gh-916.
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/css.js b/src/css.js index 5144ee9ca..9e72073eb 100644 --- a/src/css.js +++ b/src/css.js @@ -2,6 +2,9 @@ var curCSS, iframe, iframeDoc, ralpha = /alpha\([^)]*\)/i, ropacity = /opacity=([^)]*)/, rposition = /^(top|right|bottom|left)$/, + // swappable if display is none or starts with table except "table", "table-cell", or "table-caption" + // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, rmargin = /^margin/, rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ), rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ), @@ -493,12 +496,14 @@ jQuery.each([ "height", "width" ], function( i, name ) { jQuery.cssHooks[ name ] = { get: function( elem, computed, extra ) { if ( computed ) { - if ( elem.offsetWidth !== 0 || curCSS( elem, "display" ) !== "none" ) { - return getWidthOrHeight( elem, name, extra ); - } else { + // certain elements can have dimension info if we invisibly show them + // however, it must have a current display style that would benefit from this + if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) { return jQuery.swap( elem, cssShow, function() { return getWidthOrHeight( elem, name, extra ); }); + } else { + return getWidthOrHeight( elem, name, extra ); } } }, |