Skip to content

Commit

Permalink
iOS Safari 7.x has a bug with conversion numbers in `DataView#{setUin…
Browse files Browse the repository at this point in the history
…t8, setInt8}`
  • Loading branch information
zloirock committed Dec 23, 2015
1 parent 07f46a4 commit 8310c8e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions library/modules/_typed-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions modules/_typed-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8310c8e

Please sign in to comment.