From b8da068b6ebd0c0b99a3a41d9e8d9bf3f8fbc3f8 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 03b03d881ff5d4..caed9a2761835e 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 dfb7ac54900959..e6cf0571fe6530 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; } }