diff --git a/src/Angular.js b/src/Angular.js index d9333b4de70a..c8b4d77d95d4 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -909,7 +909,7 @@ function copy(source, destination) { case '[object Uint8ClampedArray]': case '[object Uint16Array]': case '[object Uint32Array]': - return new source.constructor(copyElement(source.buffer)); + return new source.constructor(copyElement(source.buffer), source.byteOffset, source.length); case '[object ArrayBuffer]': //Support: IE10 diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 25b8c45284fa..415cce3927ef 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -240,6 +240,20 @@ describe('angular', function() { } }); + it("should handle Uint16Array subarray", function() { + if (typeof Uint16Array !== 'undefined') { + var arr = new Uint16Array(4); + arr[1] = 1; + var src = arr.subarray(1, 2); + var dst = copy(src); + expect(dst instanceof Uint16Array).toBeTruthy(); + expect(dst.length).toEqual(1); + expect(dst[0]).toEqual(1); + expect(dst).not.toBe(src); + expect(dst.buffer).not.toBe(src.buffer); + } + }); + it("should throw an exception if a Uint8Array is the destination", function() { if (typeof Uint8Array !== 'undefined') { var src = new Uint8Array();