Skip to content

Avoid issues caused by clobbering of global setTimeout#1518

Merged
jrburke merged 1 commit into
requirejs:masterfrom
platinumazure:close-over-settimeout
Mar 28, 2016
Merged

Avoid issues caused by clobbering of global setTimeout#1518
jrburke merged 1 commit into
requirejs:masterfrom
platinumazure:close-over-settimeout

Conversation

@platinumazure

Copy link
Copy Markdown
Contributor

Improved version of PR #1402. Uses unqualified setTimeout as closure argument to avoid this vs global vs window issues.

The rest of this description is lifted from original PR.

Ensuring global setTimeout reference is captured in require.js so that clobbering setTimeout does not break everything.

This is useful/necessary when using RequireJS with a unit test framework that simulates setTimeout (for example sinon.js). Since RequireJS relies on the default behavior of setTimeout and is a library which ideally should function the same way even when other frameworks are involved, it seems worthwhile to close over the default setTimeout function.

I've also added a unit test file to capture this-- please let me know if that can be improved.

@jrburke jrburke added this to the 2.2.1 milestone Mar 28, 2016
@jrburke jrburke merged commit 3b5407e into requirejs:master Mar 28, 2016
@jrburke

jrburke commented Mar 28, 2016

Copy link
Copy Markdown
Member

Merged, thank you, I like this approach better.

@platinumazure

Copy link
Copy Markdown
Contributor Author

No worries, thanks for merging.
On Mar 28, 2016 12:57 AM, "James Burke" notifications@github.com wrote:

Merged, thank you, I like this approach better.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#1518 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants