-
Notifications
You must be signed in to change notification settings - Fork 20.5k
Core: Use window.setTimeout & friends when provided #2394
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
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.
Is this necessary since the globals are only removed for the built file?
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.
I removed clearInterval from JSHint globals but this is the one place where it has to appear.
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.
Of course. I was reading it all backwards.
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 looks weird without context, i would suggest add descriptive comments to each of those new files
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.
This is a long comment, see https://github.com/mzgol/jquery/blob/7eef60f491be191e5844f3a3420bee238c7d73f3/src/intro.js#L19-L25. Should I repeat this comment in every of those 4 files?
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.
I'd say link should suffice
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.
But link to what exactly? I linked to my first PR, this is the third where there is no central place to put it.
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.
Oh, then it would duplicate it everywhere :-(, would be really awkward though, or maybe just link to this pull would be enough?
|
I still question legitimacy of that ticket, we didn't receive any real issues about that and it seems only one reason why we need to do that is
Those environments should create browser-like conditions, not that other way around. If you think about it, it seems really weird, for us to do this, it is like for Firefox to change some their behaviour to keep consistency with the jsdom, which, actually should create Firefox like environment. Sounds like absurd, i bet no browser lib would do that. In other words, jsdom should create hacks and not us, and again to emphasize - we didn't received any issues which should provoke this PR. Also, @domenic could you please check it out, since it seems, we doing that just for you. Otherwise LGTM :-). |
|
There's no reason to do this. Scripts that run in jsdom can use If you run into any other "do this to support jsdom" issues, let me know and we can fix jsdom. |
The thing is those environments do provide those conditions. The current situation is that we support both scenarios:
In the (2) case we're cheating a little as we generally take stuff off this We could decide that this is an edge case that's not worth supporting but it will mean a little divergence from the (2) use case. @domenic This mostly isn't about jsdom but about running in an environment where you can provide most needed stuff via your own |
We did, the exact one I mentioned in the description of this PR... i.e. #2177. |
|
Oh, I don't really know anything about the use case of pasing in a window to a factory function. jsdom is geared around the use case of running jquery inside the jsdom environment itself, not that thing. |
|
@mzgol well, in there, owner of that ticket tries to use Deferreds (in the environment that doesn't have So i as i see it, since jsdom could work with jQuery just fine, the reason to do it is to be more consistent but a lot more hacky? Thank you for the replay @domenic, you helped a lot. |
|
Well, if we just want to assume that |
|
Also, if we want to go full-in in requiring a proper window to be present |
|
Actually, I'd be fine with requiring a proper window and moving to window.setTimeout everywhere. The problems that would cause in Node would be mitigated by using tools like jsdom along with jQuery, which is probably the only way jQuery should be used in Node anyway. Side note: we probably shouldn't recommend https://github.com/jaubourg/jquery-deferred-for-node after 3.0 comes out. It hasn't received updates in a long time and does not support Promises/A+. I know that was the point of packaging jquery deferreds separately, but it would no longer be consistent with jQuery 3.0 Deferreds. |
Let's ask @jaubourg, i thought he is still commited to supporting this module |
Why we need a window "prefix" for global vars? |
For the same reason we prefix |
|
It took me a while to catch up. In this particular case on #2177 it seems like the methods would normally be on |
|
@dmethvin This comment of mine is a good summary: #2394 (comment) We take most globals from |
|
Now i remember, okay, i agree, but i still would just write |
|
Closing in favor of #2397. |
Fixes gh-2177
Alternative to #2391 & #2392. +40 bytes.