es6-shim icon indicating copy to clipboard operation
es6-shim copied to clipboard

ES5 Array method wrappers need full implementations

Open ljharb opened this issue 10 years ago • 0 comments

Originally part of #341.

var c = 0;
[].map.call({get length(){c++;return 0}}, isNaN);
c; // => 2, should be 1 

var O = {length: Math.pow(2, 32) + 1};
O[Math.pow(2, 32)] = 42;
[].forEach.call(O, console.log, console); // => nothing, should be 42, 4294967296, O

To fix both of these, instead of calling the native methods (in the scenario where the native methods behave incorrectly for negative and over-32-bit-length array-like objects), we need to reimplement all of them in their entirety. The ideal way to do this is to require in the implementations from the es5-shim, rather than duplicating all of the tests and code.

ljharb avatar May 09 '15 22:05 ljharb