diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2017-07-31 12:36:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-31 12:36:54 -0400 |
commit | a49578499ec88c9fbca59ff0c80b23b798a55d99 (patch) | |
tree | 80d8ca0285711d25189fb1441254c062b56209f4 /src/css.js | |
parent | 262acc6f1e0f71a3a8b786e3c421b2e645799ea0 (diff) | |
download | jquery-a49578499ec88c9fbca59ff0c80b23b798a55d99.tar.gz jquery-a49578499ec88c9fbca59ff0c80b23b798a55d99.zip |
Dimensions: Improve offsetWidth/offsetHeight fallback
Fixes gh-3698
Fixes gh-3602
Closes gh-3738
Diffstat (limited to 'src/css.js')
-rw-r--r-- | src/css.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/css.js b/src/css.js index 87bf2481d..2395f42b4 100644 --- a/src/css.js +++ b/src/css.js @@ -163,10 +163,17 @@ function getWidthOrHeight( elem, dimension, extra ) { valueIsBorderBox = valueIsBorderBox && ( support.boxSizingReliable() || val === elem.style[ dimension ] ); - // Fall back to offsetWidth/Height when value is "auto" + // Fall back to offsetWidth/offsetHeight when value is "auto" // This happens for inline elements with no explicit setting (gh-3571) - if ( val === "auto" ) { + // Support: Android <=4.1 - 4.3 only + // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) + if ( val === "auto" || + !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) { + val = elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ]; + + // offsetWidth/offsetHeight provide border-box values + valueIsBorderBox = true; } // Normalize "" and auto |