Skip to content

Commit

Permalink
process: make this value consistent
Browse files Browse the repository at this point in the history
The value of `this` for callbacks of `nextTick()` can vary depending on
the number of arguments. Make it consistent.

PR-URL: #14645
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information
Trott committed Aug 10, 2017
1 parent 0d3ef5b commit a253704
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/internal/process/next_tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function setupNextTick() {
callback(args[0], args[1], args[2]);
break;
default:
callback.apply(null, args);
callback(...args);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-next-tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ process.nextTick((a, b) => {
}, 42, obj);

process.nextTick(function() {
assert.strictEqual(this, null);
assert.strictEqual(this, undefined);
}, 1, 2, 3, 4);

process.nextTick(() => {
Expand Down

0 comments on commit a253704

Please sign in to comment.