Skip to content

Fix .offset() and .position() bugs #3487

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

Merged
merged 18 commits into from
Apr 24, 2017

Conversation

gibson042
Copy link
Member

@gibson042 gibson042 commented Jan 5, 2017

Summary

Makes .offset() always relative to the document and .position() always relative to the closest containing block offsetParent (if any).

Some new tests fail on IE<11 (where document.documentElement.getBoundingClientRect() erroneously includes margins and disregards viewport scrolling), and have been manually disabled/patched up.

Fixes gh-3080
Fixes gh-3107
Closes gh-3096
Ref gh-3479

Checklist

@mention-bot
Copy link

@gibson042, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jbedard, @markelog and @dgalvez to be potential reviewers.

// TODO Verify .offset(...)
// assert.deepEqual( $el.offset( offset ).offset(), offset )
// assert.deepEqual( $el.offset( adjustedOffset ).offset(), adjustedOffset )
// assert.deepEqual( $new.offset( offset ).offset(), offset )
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omitted for scope creep. See gh-3488.

@gibson042
Copy link
Member Author

Resolved: There's no need to handle extreme situations in the broken environments.

@markelog
Copy link
Member

I think we need perf test for it

@gibson042
Copy link
Member Author

A perf test for what? I'm not aware of any alternatives here.

@timmywil timmywil assigned markelog and unassigned markelog Feb 20, 2017
@timmywil timmywil requested a review from markelog February 20, 2017 16:59
@timmywil timmywil modified the milestones: 3.3.0, 3.2.0 Mar 15, 2017
@gibson042 gibson042 force-pushed the gh-3107-offsetParent branch from 7ff4e83 to a48fed8 Compare March 20, 2017 03:54
@gibson042
Copy link
Member Author

@jquery/core This one is finally ready to land. I opened jquery/api.jquery.com#1027 to clarify some details that came to light over the course of working on it.

@gibson042 gibson042 changed the title [WIP] Fix .offset() and .position() bugs Fix .offset() and .position() bugs Mar 20, 2017
@gibson042 gibson042 merged commit 1d2df77 into jquery:master Apr 24, 2017
gibson042 added a commit to jquery/api.jquery.com that referenced this pull request Apr 25, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

.position() and .offsetParent() return incorrect value offset method returns incorrect value in Firefox
4 participants