From 47345a1f84a418cf74c99ce071bd934dccc9b587 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 4 Dec 2020 15:21:10 +0100 Subject: [PATCH] worker: refactor to use more primordials PR-URL: https://github.com/nodejs/node/pull/36393 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- lib/internal/worker/io.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/internal/worker/io.js b/lib/internal/worker/io.js index 5bec78e81fa6df..56fea9778f8785 100644 --- a/lib/internal/worker/io.js +++ b/lib/internal/worker/io.js @@ -3,6 +3,7 @@ const { ArrayPrototypeMap, ArrayPrototypePush, + FunctionPrototypeBind, FunctionPrototypeCall, ObjectAssign, ObjectCreate, @@ -348,8 +349,9 @@ class BroadcastChannel extends EventTarget { super(); this[kName] = `${name}`; this[kHandle] = broadcastChannel(this[kName]); - this[kOnMessage] = onMessageEvent.bind(this, 'message'); - this[kOnMessageError] = onMessageEvent.bind(this, 'messageerror'); + this[kOnMessage] = FunctionPrototypeBind(onMessageEvent, this, 'message'); + this[kOnMessageError] = + FunctionPrototypeBind(onMessageEvent, this, 'messageerror'); this[kHandle].on('message', this[kOnMessage]); this[kHandle].on('messageerror', this[kOnMessageError]); }