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:
Philipp von Weitershausen 2016-04-27 12:25:38 -07:00 коммит произвёл Facebook Github Bot 4
Родитель 57c40d9a6f
Коммит 8891f22f88
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;
}
}