🌐 AI搜索 & 代理 主页
Skip to content

Commit f00a075

Browse files
SaptakSgibson042
authored andcommitted
CSS: Correctly set support properties with non-default zoom
Fixes gh-3808 Closes gh-3872
1 parent 0aa832a commit f00a075

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

src/css/support.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ define( [
3030
pixelPositionVal = divStyle.top !== "1%";
3131

3232
// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
33-
reliableMarginLeftVal = divStyle.marginLeft === "12px";
33+
reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
3434

3535
// Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
3636
// Some styles come back with percentage values, even though they shouldn't
3737
div.style.right = "60%";
38-
pixelBoxStylesVal = divStyle.right === "36px";
38+
pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
3939

4040
// Support: IE 9 - 11 only
4141
// Detect misreporting of content dimensions for box-sizing:border-box elements
42-
boxSizingReliableVal = divStyle.width === "36px";
42+
boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
4343

4444
// Support: IE 9 only
4545
// Detect overflow:scroll screwiness (gh-3699)
@@ -53,6 +53,10 @@ define( [
5353
div = null;
5454
}
5555

56+
function roundPixelMeasures( measure ) {
57+
return Math.round( parseFloat( measure ) );
58+
}
59+
5660
var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
5761
reliableMarginLeftVal,
5862
container = document.createElement( "div" ),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<style>
6+
html {
7+
zoom: 1.1;
8+
}
9+
#test {
10+
width: 100px;
11+
height: 100px;
12+
padding: 10px;
13+
border: 1px solid pink;
14+
box-sizing: border-box;
15+
}
16+
</style>
17+
</head>
18+
<body>
19+
<div id="test"></div>
20+
<script src="../../jquery.js"></script>
21+
<script src="../iframeTest.js"></script>
22+
<script>
23+
startIframeTest( jQuery( "#test" ).css( 'width' ) );
24+
</script>
25+
</body>
26+
</html>

test/unit/css.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,15 @@ testIframe(
11641164
}
11651165
);
11661166

1167+
testIframe(
1168+
"css('width') should work correctly with browser zooming",
1169+
"css/cssWidthBrowserZoom.html",
1170+
function( assert, jQuery, window, document, cssWidthBrowserZoom ) {
1171+
assert.expect( 1 );
1172+
assert.strictEqual( cssWidthBrowserZoom, "100px", "elem.css('width') works correctly with browser zoom" );
1173+
}
1174+
);
1175+
11671176
( function() {
11681177
var supportsFractionalGBCR,
11691178
qunitFixture = document.getElementById( "qunit-fixture" ),

0 commit comments

Comments
 (0)