-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Offset: report offset for 0 sized elements #3367
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
Conversation
|
Thank you for your pull request. It looks like this may be your first contribution to a jQuery Foundation project, if so we need you to sign our Contributor License Agreement (CLA). 📝 Please visit http://contribute.jquery.org/CLA/ to sign. After you signed, the PR is checked again automatically after a minute. If there's still an issue, please reply here to let us know. If you've already signed our CLA, it's possible your git author information doesn't match your CLA signature (both your name and email have to match), for more information, check the status of your CLA check. |
|
So, do we want to report left/top for 0 sized elements? If not, then it can be simpler this: if ( rect.width || rect.height ) {
// ...
} else {
return { left: 0, top: 0 }
} |
|
Oh, nevermind, 0 sized elements still can provide some visible objects (child elements / text) so definitely should return correct offset. |
|
LGTM. 👍 |
|
LGTM |
|
We can now write |
I assume this previously worked (except IE<=11+ which crashed) before 0e4477c.
Also previously when
if ( rect.width || rect.height )failed it would returnrectwhich would be thegetBoundingClientRect()object containing top/bottom/left/right along with the width/height of 0. The top/left in there would probably be quite misleading?Fixes gh-3267