-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: nextTick timing regression (#1573)
* fix: nextTick timing regression
- Loading branch information
1 parent
c96df0e
commit 65ecb6f
Showing
5 changed files
with
31 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = | ||
typeof setImmediate === "function" | ||
? setImmediate | ||
: (function() { | ||
var queue = []; | ||
var win = window; | ||
var msg = "" + Math.random(); | ||
win.addEventListener("message", function(ev) { | ||
if (ev.data === msg) { | ||
var callbacks = queue; | ||
queue = []; | ||
for (var i = 0; i < callbacks.length; i++) { | ||
callbacks[i](); | ||
} | ||
} | ||
}); | ||
return function(callback) { | ||
if (queue.push(callback) === 1) { | ||
win.postMessage(msg, "*"); | ||
} | ||
}; | ||
})(); |