Skip to content

Commit

Permalink
Don't swap to measure dimensions unless the element is display:none. #…
Browse files Browse the repository at this point in the history
…807 Fixes #11293
  • Loading branch information
mikesherov authored and rwaldron committed Jun 7, 2012
1 parent 79af1b4 commit c80bc22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/css.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
jQuery.cssHooks[ name ] = { jQuery.cssHooks[ name ] = {
get: function( elem, computed, extra ) { get: function( elem, computed, extra ) {
if ( computed ) { if ( computed ) {
if ( elem.offsetWidth !== 0 ) { if ( elem.offsetWidth !== 0 || curCSS( elem, "display" ) !== "none" ) {
return getWidthOrHeight( elem, name, extra ); return getWidthOrHeight( elem, name, extra );
} else { } else {
return jQuery.swap( elem, cssShow, function() { return jQuery.swap( elem, cssShow, function() {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/dimensions.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ test("outerWidth(true) returning % instead of px in Webkit, see #10639", functio
equal( el.outerWidth(true), 400, "outerWidth(true) and css('margin') returning % instead of px in Webkit, see #10639" ); equal( el.outerWidth(true), 400, "outerWidth(true) and css('margin') returning % instead of px in Webkit, see #10639" );
}); });


test( "getting dimensions of zero width/height table elements shouldn't alter dimensions", function() {
expect( 1 );

var table = jQuery("<table><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>").appendTo("#qunit-fixture"),
elem = table.find("tr:eq(0) td:eq(0)");

table.find("td").css({ margin: 0, padding: 0 });
equal( elem.width(), elem.width(), "width() doesn't alter dimension values" );
});

test("box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function() { test("box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function() {
expect(16); expect(16);


Expand Down

0 comments on commit c80bc22

Please sign in to comment.