valueIsBorderBox = isBorderBox &&
( support.boxSizingReliable() || val === elem.style[ name ] );
+ // Fall back to offsetWidth/Height when value is "auto"
+ // This happens for inline elements with no explicit setting (gh-3571)
+ if ( val === "auto" ) {
+ val = elem[ "offset" + name[ 0 ].toUpperCase() + name.slice( 1 ) ];
+ }
+
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;
"use strict";
function curCSS( elem, name, computed ) {
- var width, minWidth, maxWidth, ret,
- style = elem.style;
+ var width, minWidth, maxWidth, ret, style;
computed = computed || getStyles( elem );
// This is against the CSSOM draft spec:
// https://drafts.csswg.org/cssom/#resolved-values
if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
+ style = elem.style;
// Remember the original values
width = style.width;
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" );
+ } );
+} );
+
} )();