diff options
author | Saptak Sengupta <saptak013@gmail.com> | 2017-12-06 10:29:54 +0530 |
---|---|---|
committer | Richard Gibson <richard.gibson@gmail.com> | 2017-12-05 23:59:54 -0500 |
commit | f00a07590e67777f4e6b8f452059b116d922a623 (patch) | |
tree | 698a3e5e4001cd32ac65d2c8115a7efc13a550ad | |
parent | 0aa832afec04215ed5e14b1cc5fc287ad7939792 (diff) | |
download | jquery-f00a07590e67777f4e6b8f452059b116d922a623.tar.gz jquery-f00a07590e67777f4e6b8f452059b116d922a623.zip |
CSS: Correctly set support properties with non-default zoom
Fixes gh-3808
Closes gh-3872
-rw-r--r-- | src/css/support.js | 10 | ||||
-rw-r--r-- | test/data/css/cssWidthBrowserZoom.html | 26 | ||||
-rw-r--r-- | test/unit/css.js | 9 |
3 files changed, 42 insertions, 3 deletions
diff --git a/src/css/support.js b/src/css/support.js index 5404f8cd8..dbb7ef7ce 100644 --- a/src/css/support.js +++ b/src/css/support.js @@ -30,16 +30,16 @@ define( [ pixelPositionVal = divStyle.top !== "1%"; // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 - reliableMarginLeftVal = divStyle.marginLeft === "12px"; + reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 // Some styles come back with percentage values, even though they shouldn't div.style.right = "60%"; - pixelBoxStylesVal = divStyle.right === "36px"; + pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; // Support: IE 9 - 11 only // Detect misreporting of content dimensions for box-sizing:border-box elements - boxSizingReliableVal = divStyle.width === "36px"; + boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; // Support: IE 9 only // Detect overflow:scroll screwiness (gh-3699) @@ -53,6 +53,10 @@ define( [ div = null; } + function roundPixelMeasures( measure ) { + return Math.round( parseFloat( measure ) ); + } + var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, reliableMarginLeftVal, container = document.createElement( "div" ), diff --git a/test/data/css/cssWidthBrowserZoom.html b/test/data/css/cssWidthBrowserZoom.html new file mode 100644 index 000000000..99f87ea29 --- /dev/null +++ b/test/data/css/cssWidthBrowserZoom.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="utf-8"> + <style> + html { + zoom: 1.1; + } + #test { + width: 100px; + height: 100px; + padding: 10px; + border: 1px solid pink; + box-sizing: border-box; + } + </style> +</head> +<body> +<div id="test"></div> +<script src="../../jquery.js"></script> +<script src="../iframeTest.js"></script> +<script> + startIframeTest( jQuery( "#test" ).css( 'width' ) ); +</script> +</body> +</html> diff --git a/test/unit/css.js b/test/unit/css.js index 285ad2ef0..2ca72c1aa 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1164,6 +1164,15 @@ testIframe( } ); +testIframe( + "css('width') should work correctly with browser zooming", + "css/cssWidthBrowserZoom.html", + function( assert, jQuery, window, document, cssWidthBrowserZoom ) { + assert.expect( 1 ); + assert.strictEqual( cssWidthBrowserZoom, "100px", "elem.css('width') works correctly with browser zoom" ); + } +); + ( function() { var supportsFractionalGBCR, qunitFixture = document.getElementById( "qunit-fixture" ), |