Remove guard that we used in iOS 7 to avoid a JS crash
Summary: JSC on iOS 8 and above includes TypedArrays so there's no need for the guard statement anymore since React Native officially does not support iOS 7 moving forward. Closes https://github.com/facebook/react-native/pull/9780 Differential Revision: D3834979 Pulled By: mkonicek fbshipit-source-id: 6e28a47702d6e3d604fedb9d2d00fe1c539a6926
This commit is contained in:
parent
532751f8a8
commit
ad24bcf7cc
|
@ -118,18 +118,15 @@ class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Maintain iOS 7 compatibility which doesn't have JS typed arrays.
|
||||
if (typeof ArrayBuffer !== 'undefined' &&
|
||||
typeof Uint8Array !== 'undefined') {
|
||||
if (ArrayBuffer.isView(data)) {
|
||||
// $FlowFixMe: no way to assert that 'data' is indeed an ArrayBufferView now
|
||||
data = data.buffer;
|
||||
}
|
||||
if (data instanceof ArrayBuffer) {
|
||||
data = base64.fromByteArray(new Uint8Array(data));
|
||||
RCTWebSocketModule.sendBinary(data, this._socketId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ArrayBuffer.isView(data)) {
|
||||
// $FlowFixMe: no way to assert that 'data' is indeed an ArrayBufferView now
|
||||
data = data.buffer;
|
||||
}
|
||||
if (data instanceof ArrayBuffer) {
|
||||
data = base64.fromByteArray(new Uint8Array(data));
|
||||
RCTWebSocketModule.sendBinary(data, this._socketId);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error('Unsupported data type');
|
||||
|
|
Loading…
Reference in New Issue