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
html element offset does accounting margins contrary to docs #4863
Comments
Background information:
Whether or not the document element establishes an absolute positioning containing block, I believe that the origin identified above (subject to the positioning scheme of the document element) is the most useful origin for |
I also lean towards using the document element and make it conditional on absolute position. |
I'm still not sure whether it's a breaking change. You could read the existing docs in different ways. If you read it as relative to the document element (which makes more sense to me as it's concrete), then this is a bug fix. |
Discussed in the meeting. Because it's been this way for so long, we'll treat it as a breaking change for 4.0. |
Description
Hi,
This is regarding the latest jQuery version (3.x).
When running
$('html').offset()
when the element has a margin-top or margin-left, the values are equals to those margins.On old versions of jQuery, I always get zero for top and left values which are the expected values. It's also mentioned in the docs, as said: "Note: jQuery does not support getting the offset coordinates of hidden elements or accounting for margins set on the document element." )
See JSBin below.
Use case example is Select2 library which calculates the dropdown position based on the
<html>
element. Those wrong values ofoffset()
output cause the dropdown to be placed incorrectly. See this issue from WordPress support forum.Link to test case
jQuery 3: https://jsbin.com/dixilusupe/edit?html,css,js,output
jQuery 1: https://jsbin.com/vadudamufa/edit?html,css,js,output
The text was updated successfully, but these errors were encountered: