|
|
@@ -148,10 +148,10 @@ function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computed |
|
|
function getWidthOrHeight( elem, dimension, extra ) {
|
|
|
|
|
|
// Start with computed style
|
|
|
- var valueIsBorderBox,
|
|
|
- styles = getStyles( elem ),
|
|
|
+ var styles = getStyles( elem ),
|
|
|
val = curCSS( elem, dimension, styles ),
|
|
|
- isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
|
|
|
+ isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
|
+ valueIsBorderBox = isBorderBox;
|
|
|
|
|
|
// Computed unit is not pixels. Stop here and return.
|
|
|
if ( rnumnonpx.test( val ) ) {
|
|
|
@@ -160,7 +160,7 @@ function getWidthOrHeight( elem, dimension, extra ) { |
|
|
|
|
|
// Check for style in case a browser which returns unreliable values
|
|
|
// for getComputedStyle silently falls back to the reliable elem.style
|
|
|
- valueIsBorderBox = isBorderBox &&
|
|
|
+ valueIsBorderBox = valueIsBorderBox &&
|
|
|
( support.boxSizingReliable() || val === elem.style[ dimension ] );
|
|
|
|
|
|
// Fall back to offsetWidth/Height when value is "auto"
|
|
|
@@ -367,14 +367,26 @@ jQuery.each( [ "height", "width" ], function( i, dimension ) { |
|
|
set: function( elem, value, extra ) {
|
|
|
var matches,
|
|
|
styles = getStyles( elem ),
|
|
|
+ isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
|
subtract = extra && boxModelAdjustment(
|
|
|
elem,
|
|
|
dimension,
|
|
|
extra,
|
|
|
- jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
|
|
|
+ isBorderBox,
|
|
|
styles
|
|
|
);
|
|
|
|
|
|
+ // Account for unreliable border-box dimensions by comparing offset* to computed and
|
|
|
+ // faking a content-box to get border and padding (gh-3699)
|
|
|
+ if ( isBorderBox && !support.borderBoxReliable() ) {
|
|
|
+ subtract -= Math.ceil(
|
|
|
+ elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
|
|
|
+ parseFloat( styles[ dimension ] ) -
|
|
|
+ boxModelAdjustment( elem, dimension, "border", false, styles ) -
|
|
|
+ 0.5
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
// Convert to pixels if value adjustment is needed
|
|
|
if ( subtract && ( matches = rcssNum.exec( value ) ) &&
|
|
|
( matches[ 3 ] || "px" ) !== "px" ) {
|
|
|
|
Krinkle commented onJul 18, 2017
•
edited
3fcddd6This commit appears to have broken the support tests in all browsers. Still the case on latest master.
See: #3730
It also broke the dimensions tests in IE 10 and IE 11.
See: #3731