New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the width calculation of border-box due to browser zoom #3872
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few tweaks, then looks good to me. Thanks @SaptakS!
src/css/support.js
Outdated
@@ -53,6 +53,11 @@ define( [ | |||
div = null; | |||
} | |||
|
|||
// Rounding up the exact checking match values | |||
function roundPixelMeasures( measure ) { | |||
return Math.round( parseFloat( measure ) ) + "px"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding "px" seems pointless, we should just return and compare against the numeric value (saving a few bytes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed "px" and used the numeric values to compare, since it saves a few bytes in both the places as suggested by you.
src/css/support.js
Outdated
@@ -53,6 +53,11 @@ define( [ | |||
div = null; | |||
} | |||
|
|||
// Rounding up the exact checking match values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this comment confusing. And given the clarity of the function body, it can probably just be dropped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped the comment as suggested by you.
<meta charset="utf-8"> | ||
<style> | ||
html { | ||
zoom: 1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a semicolon for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved ✔️
@gibson042 will fix these. But the problem is the unittest actually doesn't reproduce the error. So we won't be able to confirm in future if this feature is broken. Can you please help in that as well? |
The unit test worked for me in Chromium 62 on Linux... assertion failed with the old code and passed with the changes. |
Signed-off-by: Saptak Sengupta <saptak013@gmail.com>
…zoom Signed-off-by: Saptak Sengupta <saptak013@gmail.com>
@gibson042 made the changes as suggested by you. |
When will this change be published to NPM? |
Later this month, as part of jQuery 3.3. |
Hi, is there any hope for backporting it to the older versions? |
You could certainly try to back-port it. We're not supporting older versions so if you want a supported version you should upgrade. |
@dmethvin is there any maintenance for the v2.x ? Of course updating to the latest version is preferred, but in some cases some projects are simply too large to port overnight, when some minor issue like this one is discovered. |
You're always welcome to port over a "minor issue" for your own use. There's more work than you might think to maintain an old version, especially when it comes to test infrastructure. |
Summary
The pull request mainly has two tasks done:
However the test for the issue isn't working. I used an iframe test to check for the border-box width at
html {zoom: 1.1}
. Though opening the html file separately recreates the issue, but via the unittest code, it doesn't.Some help in fixing the unittest will be really helpful.
Checklist