From 8891f22f887a21a55378087527c70e574e4cf00e Mon Sep 17 00:00:00 2001 From: Philipp von Weitershausen Date: Wed, 27 Apr 2016 12:25:38 -0700 Subject: [PATCH] Fix WebSocket compatibility with event-target-shim ^1.0.5 Summary: event-target-shim versions before 1.1.0 do not support taking an array for `EventTarget`. react-native requires `^1.0.5`, so this fixes compatibility with those earlier versions. **Test Plan:** ran WebSocket UIExplorer example with earlier version of event-target-shim. Closes https://github.com/facebook/react-native/pull/7261 Differential Revision: D3230881 Pulled By: martinbigio fb-gh-sync-id: 6a22d58841a4b401a200fece64d13a70043fb09a fbshipit-source-id: 6a22d58841a4b401a200fece64d13a70043fb09a --- Libraries/WebSocket/WebSocket.js | 2 +- Libraries/WebSocket/__mocks__/event-target-shim.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/WebSocket/WebSocket.js b/Libraries/WebSocket/WebSocket.js index 03b03d881..caed9a276 100644 --- a/Libraries/WebSocket/WebSocket.js +++ b/Libraries/WebSocket/WebSocket.js @@ -55,7 +55,7 @@ let nextWebSocketId = 0; * See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket * See https://github.com/websockets/ws */ -class WebSocket extends EventTarget(WEBSOCKET_EVENTS) { +class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) { static CONNECTING = CONNECTING; static OPEN = OPEN; static CLOSING = CLOSING; diff --git a/Libraries/WebSocket/__mocks__/event-target-shim.js b/Libraries/WebSocket/__mocks__/event-target-shim.js index dfb7ac549..e6cf0571f 100644 --- a/Libraries/WebSocket/__mocks__/event-target-shim.js +++ b/Libraries/WebSocket/__mocks__/event-target-shim.js @@ -8,9 +8,9 @@ 'use strict'; function EventTarget() { - // Support both EventTarget and EventTarget([list, of, events]) + // Support both EventTarget and EventTarget(...) // as a super class, just like the original module does. - if (arguments.length === 1 && Array.isArray(arguments[0])) { + if (arguments.length > 0) { return EventTarget; } }