Skip to content

Commit

Permalink
Fix WebSocket compatibility with event-target-shim ^1.0.5
Browse files Browse the repository at this point in the history
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 facebook#7261

Differential Revision: D3230881

Pulled By: martinbigio

fb-gh-sync-id: 6a22d58841a4b401a200fece64d13a70043fb09a
fbshipit-source-id: 6a22d58841a4b401a200fece64d13a70043fb09a
  • Loading branch information
philikon authored and zebulgar committed Jun 18, 2016
1 parent 885bfcf commit b8da068
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Libraries/WebSocket/WebSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Libraries/WebSocket/__mocks__/event-target-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit b8da068

Please sign in to comment.