Skip to content

All: Resolve most jQuery Migrate warnings #1919

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 1 commit into from
May 16, 2020
Merged

Conversation

mgol
Copy link
Member

@mgol mgol commented May 13, 2020

This also adds a new internal $.ui.__safeOffset__ method to provide a similar support to past jQuery versions while avoiding Migrate warnings. this part is now extracted to #1922.

@mgol mgol requested review from fnagel and arschmitz May 13, 2020 08:01
@mgol mgol force-pushed the migrate-warnings branch 2 times, most recently from eacb8e3 to e2a60e3 Compare May 13, 2020 08:12
@@ -331,7 +331,7 @@ $.widget( "ui.tooltip", {
position( positionOption.of );
clearInterval( delayedShow );
}
}, $.fx.interval );
}, 13 );
Copy link
Member

Choose a reason for hiding this comment

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

Do we want a comment here why its 13?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. This is copied from the $.fx.interval value & follows the advice from https://github.com/jquery/jquery-migrate/blob/master/warnings.md#jqmigrate-jqueryfxinterval-is-deprecated


// Simulate a jQuery short-circuiting when there are no client rects reported
// which usually means a disconnected node. This check in jQuery is meant just
// for IE but UI depends on it.
Copy link
Member

Choose a reason for hiding this comment

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

Just for my understanding: this check is implemented in jQuery for IE only, bit UI needs it in every browser, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not exactly. jQuery has a check meant for IE but it's run by all browsers so by pure coincidence it makes UI not hit errors here. This is about these lines:
https://github.com/jquery/jquery/blob/3.5.1/src/offset.js#L98-L104

Copy link
Member Author

Choose a reason for hiding this comment

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

How about:

Suggested change
// for IE but UI depends on it.
// for IE but is applied in all browsers & UI depends on it.

?

Copy link
Member

Choose a reason for hiding this comment

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

I still don't understand why we need this in jQueryUI when its already in jQuery... sorry, my mind is a little slow today ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

See https://jquery.com/upgrade-guide/3.0/#breaking-change-invalid-input-to-the-offset-method

jQuery 3.0.0 & newer require DOM elements with the getBoundingClientRect method. It's just that jQuery needs to run a check for getClientRects() due to the comment above the lines I linked, to workaround an IE issue. We shouldn't rely on this check for other purposes.

Also, jQuery Migrate warns if you use offset() in such a way.

That said, now I see the discussion in jquery/jquery#2310 so maybe I need to re-read it & make sure Migrate is not warning too much.

Copy link
Member

Choose a reason for hiding this comment

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

Ahhh, got it. Thanks for the explanation and your patience :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

@fnagel Thank you for raising these concerns! This change will most likely not be needed as we'll update Migrate instead.

Copy link
Member

@fnagel fnagel left a comment

Choose a reason for hiding this comment

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

+1 by reading

@mgol mgol force-pushed the migrate-warnings branch from e2a60e3 to 5a67e59 Compare May 16, 2020 06:33
@mgol mgol merged commit f4ef03e into jquery:master May 16, 2020
@mgol mgol deleted the migrate-warnings branch May 16, 2020 06:36
@mgol
Copy link
Member Author

mgol commented May 16, 2020

@fnagel There are some things to check for me in comments about offset changes. I didn't want to delay other changes so I extracted the second commit to #1922 & only landed the first one here.

@mgol mgol added this to the 1.13 milestone Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants