From a2537044463ffa200d781e15b4768be4bf9dbf8d Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 5 Aug 2017 19:10:21 -0700 Subject: [PATCH] process: make `this` value consistent The value of `this` for callbacks of `nextTick()` can vary depending on the number of arguments. Make it consistent. PR-URL: https://github.com/nodejs/node/pull/14645 Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Refael Ackermann --- lib/internal/process/next_tick.js | 2 +- test/parallel/test-next-tick.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/process/next_tick.js b/lib/internal/process/next_tick.js index 685fa6717bd9f1..00698aee23020b 100644 --- a/lib/internal/process/next_tick.js +++ b/lib/internal/process/next_tick.js @@ -141,7 +141,7 @@ function setupNextTick() { callback(args[0], args[1], args[2]); break; default: - callback.apply(null, args); + callback(...args); } } } diff --git a/test/parallel/test-next-tick.js b/test/parallel/test-next-tick.js index 511d0559cd1e94..47823f45bcf7e2 100644 --- a/test/parallel/test-next-tick.js +++ b/test/parallel/test-next-tick.js @@ -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(() => {