Skip to content

Commit

Permalink
Merge pull request #233 from shdq/queueMicrotask-warning
Browse files Browse the repository at this point in the history
[WIP] queueMicrotask() ExperimentalWarning in Node
  • Loading branch information
benjamingr committed Apr 13, 2019
2 parents 0fcf9cd + 5ba40ee commit 35f5305
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/lolex-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function withGlobal(_global) {
var nextTickPresent = (_global.process && typeof _global.process.nextTick === "function");
var performancePresent = (_global.performance && typeof _global.performance.now === "function");
var hasPerformancePrototype = (_global.Performance && (typeof _global.Performance).match(/^(function|object)$/));
var queueMicrotaskPresent = (typeof _global.queueMicrotask === "function");
var queueMicrotaskPresent = (_global.hasOwnProperty("queueMicrotask"));
var requestAnimationFramePresent = (
_global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function"
);
Expand Down Expand Up @@ -493,8 +493,9 @@ function withGlobal(_global) {
if (requestAnimationFramePresent) {
timers.requestAnimationFrame = _global.requestAnimationFrame;
}

if (queueMicrotaskPresent) {
timers.queueMicrotask = _global.queueMicrotask;
timers.queueMicrotask = true;
}

if (cancelAnimationFramePresent) {
Expand Down Expand Up @@ -897,7 +898,9 @@ function withGlobal(_global) {

if (clock.methods.length === 0) {
// do not fake nextTick by default - GitHub#126
clock.methods = keys(timers).filter(function (key) {return key !== "nextTick";});
clock.methods = keys(timers).filter(function (key) {
return key !== "nextTick" && key !== "queueMicrotask";
});
}

for (i = 0, l = clock.methods.length; i < l; i++) {
Expand Down
2 changes: 1 addition & 1 deletion test/lolex-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@ describe("lolex", function () {
});
it("runs with timers and before them", function () {
var last = "";
clock.runMicrotasks(function () {
clock.queueMicrotask(function () {
called = true;
last = "tick";
});
Expand Down

0 comments on commit 35f5305

Please sign in to comment.