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
This commit is contained in:
parent
57c40d9a6f
commit
8891f22f88
|
@ -55,7 +55,7 @@ let nextWebSocketId = 0;
|
||||||
* See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
|
* See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
|
||||||
* See https://github.com/websockets/ws
|
* See https://github.com/websockets/ws
|
||||||
*/
|
*/
|
||||||
class WebSocket extends EventTarget(WEBSOCKET_EVENTS) {
|
class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) {
|
||||||
static CONNECTING = CONNECTING;
|
static CONNECTING = CONNECTING;
|
||||||
static OPEN = OPEN;
|
static OPEN = OPEN;
|
||||||
static CLOSING = CLOSING;
|
static CLOSING = CLOSING;
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function EventTarget() {
|
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.
|
// as a super class, just like the original module does.
|
||||||
if (arguments.length === 1 && Array.isArray(arguments[0])) {
|
if (arguments.length > 0) {
|
||||||
return EventTarget;
|
return EventTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue