-
Notifications
You must be signed in to change notification settings - Fork 476
Offset: fix wrong origin value #334
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
offset should return undefined instead of {top:0,left:0} for non DOM element.
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.
Looks good, thanks!
When will this be merged? |
I'd like @dmethvin to do a review as well but I'd like to get it in a Migrate 3.2.0 release that is likely to be available within a week or two. |
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.
Need to return the bogus
for things without a nodeType
, but otherwise good.
|
||
if ( !elem || !elem.nodeType ) { | ||
migrateWarn( "jQuery.fn.offset() requires a valid DOM element" ); | ||
return origin; |
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.
We only want to return undefined
for the !elem
case. Some code including older older versions of jQuery UI would pass window
and expect the top/left of 0. jquery/jquery#3249
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.
Does it expect {left:0,top:0}
for window
? Why both 1.12.4
and 2.2.4
return undefined
as I tested?
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.
It sure does, thanks for catching that! I don't have time to look at it right now but I must have been thinking of some other edge case with .offset()
? Looks like that ticket is specifically about calling a method on window
, not returning the bogus value.
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.
@dmethvin Since the issue was about a breaking change in jQuery 3.0.0, it seems we shouldn't care about it here as Migrate 3.x is meant to aid with upgrading to the future jQuery 4.0. Am I missing anything?
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.
👍
Fixes #330 .
offset
should returnundefined
instead of{top:0,left:0}
for non DOM element.