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

Conversation

@mgol
Copy link
Member

@mgol mgol commented Mar 30, 2023

Summary

This regressed in gh-3656 as the added logic to include scroll gutters in .innerWidth() / .innerHeight() didn't take negative margins into account. This broke handling of negative margins in .offsetHeight( true ) and .offsetWidth( true ). To fix it, calculate margin delta separately and only add it after the scroll gutter adjustment logic.

Fixes gh-3982
Ref gh-3656

+4 bytes

Checklist

  • New tests have been added to show the fix or feature works
  • Grunt build and unit tests pass locally with these changes
  • If needed, a docs issue/PR was created at https://github.com/jquery/api.jquery.com

This regressed in jquerygh-3656 as the added logic to include scroll gutters
in `.innerWidth()` / `.innerHeight()` didn't take negative margins into
account. This broke handling of negative margins in
`.offsetHeight( true )` and `.offsetWidth( true )`. To fix it, calculate
margin delta separately and only add it after the scroll gutter
adjustment logic.

Fixes jquerygh-3982
Ref jquerygh-3656
@mgol mgol added CSS Needs review Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. labels Mar 30, 2023
@mgol mgol added this to the 3.7.0 milestone Mar 30, 2023
@mgol mgol self-assigned this Mar 30, 2023
@timmywil timmywil removed the Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. label Apr 3, 2023
@mgol
Copy link
Member Author

mgol commented Apr 4, 2023

@gibson042 I'd like to start asking some projects to test against 3.x-git as a way to verify we didn't break anything with some of the more risky changes so I'll land this. If you have different ideas on how to address it, we can address them separately later.

@mgol mgol removed the Needs review label Apr 4, 2023
@mgol mgol merged commit bce13b7 into jquery:main Apr 4, 2023
@mgol mgol deleted the offsetHeight-negative-margins branch April 4, 2023 14:00
mgol added a commit that referenced this pull request Apr 4, 2023
This regressed in gh-3656 as the added logic to include scroll gutters
in `.innerWidth()` / `.innerHeight()` didn't take negative margins into
account. This broke handling of negative margins in
`.offsetHeight( true )` and `.offsetWidth( true )`. To fix it, calculate
margin delta separately and only add it after the scroll gutter
adjustment logic.

Fixes gh-3982
Closes gh-5234
Ref gh-3656

(cherry picked from commit bce13b7)
@mgol
Copy link
Member Author

mgol commented Apr 4, 2023

Landed on main in bce13b7 and on 3.x-stable in 7bb48a0.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

outerHeight(true) does not handle negative margins properly (starting with 3.3.x release)

2 participants