Skip to content

Commit

Permalink
Fixes ArrayBuffer and TypedArray.prototype.@@iterator detection i…
Browse files Browse the repository at this point in the history
…n IE11
  • Loading branch information
mhassan1 committed Jul 10, 2024
1 parent c05a288 commit 288a4e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions polyfills/ArrayBuffer/detect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// use "Int8Array" as a proxy for support of "TypedArray" subclasses
// confirm that the prototype of "Int8Array" is NOT the "Object" prototype, which is a bug in IE11 and maybe other old browsers
'ArrayBuffer' in self && 'DataView' in self && 'Int8Array' in self
// IE11 has an incomplete implementation that's missing `slice` and maybe others
&& 'slice' in self.Int8Array.prototype
// TODO: add back this check once we remove support for ie10 and below
// && Object.getPrototypeOf(self.Int8Array) !== Object.getPrototypeOf(Object)
2 changes: 1 addition & 1 deletion polyfills/TypedArray/prototype/@@iterator/detect.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// use "Int8Array" as a proxy for support of "TypedArray" subclasses
'Symbol' in self && 'iterator' in self.Symbol && 'Int8Array' in self && self.Symbol.iterator in self.Int8Array.prototype
'Symbol' in self && 'iterator' in self.Symbol && 'Int8Array' in self && self.Symbol.iterator in self.Int8Array.prototype && self.Int8Array.prototype[self.Symbol.iterator] !== undefined
2 changes: 2 additions & 0 deletions polyfills/TypedArray/prototype/@@iterator/polyfill.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

it('is an alias to %TypedArray%.prototype.values', function () {
if ('__proto__' in Int8Array.prototype && self.Int8Array.prototype.__proto__ !== Object.prototype) {
proclaim.isDefined(Int8Array.prototype.__proto__[Symbol.iterator]);
proclaim.deepEqual(Int8Array.prototype.__proto__[Symbol.iterator], Int8Array.prototype.__proto__.values);
} else {
proclaim.isDefined(Int8Array.prototype[Symbol.iterator]);
proclaim.deepEqual(Int8Array.prototype[Symbol.iterator], Int8Array.prototype.values);
}
});

0 comments on commit 288a4e4

Please sign in to comment.