From 8310c8e42af596d2ce23216efb82f6e3f56677e7 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Wed, 23 Dec 2015 16:35:38 +0600 Subject: [PATCH] iOS Safari 7.x has a bug with conversion numbers in `DataView#{setUint8, setInt8}` --- library/modules/_typed-buffer.js | 12 ++++++++++++ modules/_typed-buffer.js | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/library/modules/_typed-buffer.js b/library/modules/_typed-buffer.js index d386c772a6fd..160a4542ea5c 100644 --- a/library/modules/_typed-buffer.js +++ b/library/modules/_typed-buffer.js @@ -255,6 +255,18 @@ if(!$typed.ABV){ var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE]; if(!LIBRARY)ArrayBufferProto.constructor = $ArrayBuffer; } + // iOS Safari 7.x bug + var view = new $DataView(new $ArrayBuffer(8)) + , $setInt8 = $DataView[PROTOTYPE].setInt8; + view.setInt8(0, 2147483649); + view.getInt8(0) || redefineAll($DataView[PROTOTYPE], { + setInt8: function setInt8(byteOffset, value){ + $setInt8.call(this, byteOffset, value << 24 >> 24); + }, + setUint8: function setUint8(byteOffset, value){ + $setInt8.call(this, byteOffset, value << 24 >> 24); + } + }, true); } setToStringTag($ArrayBuffer, ARRAY_BUFFER); setToStringTag($DataView, DATA_VIEW); diff --git a/modules/_typed-buffer.js b/modules/_typed-buffer.js index d386c772a6fd..160a4542ea5c 100644 --- a/modules/_typed-buffer.js +++ b/modules/_typed-buffer.js @@ -255,6 +255,18 @@ if(!$typed.ABV){ var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE]; if(!LIBRARY)ArrayBufferProto.constructor = $ArrayBuffer; } + // iOS Safari 7.x bug + var view = new $DataView(new $ArrayBuffer(8)) + , $setInt8 = $DataView[PROTOTYPE].setInt8; + view.setInt8(0, 2147483649); + view.getInt8(0) || redefineAll($DataView[PROTOTYPE], { + setInt8: function setInt8(byteOffset, value){ + $setInt8.call(this, byteOffset, value << 24 >> 24); + }, + setUint8: function setUint8(byteOffset, value){ + $setInt8.call(this, byteOffset, value << 24 >> 24); + } + }, true); } setToStringTag($ArrayBuffer, ARRAY_BUFFER); setToStringTag($DataView, DATA_VIEW);