aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/dimensions.js
diff options
context:
space:
mode:
authorTimmy Willison <4timmywil@gmail.com>2017-03-18 14:19:32 -0400
committerTimmy Willison <4timmywil@gmail.com>2017-03-20 12:16:12 -0400
commit473d2ea7d5e4ef0a5b8e0305197f483c136ee4ab (patch)
tree0ad1c6237b7495a8d9520f77283c1920ec70ce33 /test/unit/dimensions.js
parentfcc9a9ec9685e25864ca793698e4ac5e60226272 (diff)
downloadjquery-473d2ea7d5e4ef0a5b8e0305197f483c136ee4ab.tar.gz
jquery-473d2ea7d5e4ef0a5b8e0305197f483c136ee4ab.zip
Dimensions: fall back to offsetWidth/Height for inline elems
Close gh-3577 Fixes gh-3571
Diffstat (limited to 'test/unit/dimensions.js')
-rw-r--r--test/unit/dimensions.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js
index 1bf4ae2aa..cba821185 100644
--- a/test/unit/dimensions.js
+++ b/test/unit/dimensions.js
@@ -538,4 +538,18 @@ QUnit.test( "width/height on element with transform (gh-3193)", function( assert
assert.equal( $elem.height(), 200, "Height ignores transforms" );
} );
+QUnit.test( "width/height on an inline element with no explicitly-set dimensions (gh-3571)", function( assert ) {
+ assert.expect( 8 );
+
+ var $elem = jQuery( "<span style='border: 2px solid black;padding: 1px;margin: 3px;'>Hello, I'm some text.</span>" ).appendTo( "#qunit-fixture" );
+
+ jQuery.each( [ "Width", "Height" ], function( i, method ) {
+ var val = $elem[ method.toLowerCase() ]();
+ assert.notEqual( val, 0, method + " should not be zero on inline element." );
+ assert.equal( $elem[ "inner" + method ](), val + 2, "inner" + method + " should include padding" );
+ assert.equal( $elem[ "outer" + method ](), val + 6, "outer" + method + " should include padding and border" );
+ assert.equal( $elem[ "outer" + method ]( true ), val + 12, "outer" + method + "(true) should include padding, border, and margin" );
+ } );
+} );
+
} )();