From 4dfb299253d769fafe12f33265f17f40059a0553 Mon Sep 17 00:00:00 2001 From: Saptak Sengupta Date: Mon, 4 Dec 2017 15:04:53 +0530 Subject: [PATCH] CSS: Round off pixel measures to fix box-size discrepency on browser zoom Signed-off-by: Saptak Sengupta --- src/css/support.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/css/support.js b/src/css/support.js index 5404f8cd881..2ae10dba41b 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 ) === "12px"; // 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 ) === "36px"; // Support: IE 9 - 11 only // Detect misreporting of content dimensions for box-sizing:border-box elements - boxSizingReliableVal = divStyle.width === "36px"; + boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === "36px"; // Support: IE 9 only // Detect overflow:scroll screwiness (gh-3699) @@ -53,6 +53,11 @@ define( [ div = null; } + // Rounding up the exact checking match values + function roundPixelMeasures( measure ) { + return Math.round( parseFloat( measure ) ) + "px"; + } + var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, reliableMarginLeftVal, container = document.createElement( "div" ),