Avoid _.extend in IE8-sensitive ecmascript tests.

The underlying problem is that `es5-shim` polyfills `Array.prototype`
methods in IE8, but it can't actually make them non-enumerable, so
`_.extend` copies them, because it doesn't check `hasOwnProperty`.

This probably calls for a more general audit of for-in loops over objects
that could be Arrays, especially within underscore.
This commit is contained in:
Ben Newman
2015-07-24 16:54:11 -04:00
parent 05c2165580
commit ba0aa4d709

View File

@@ -1,7 +1,10 @@
Tinytest.add("ecmascript - runtime - template literals", (test) => {
function dump(pieces) {
return [_.extend({}, pieces),
_.toArray(arguments).slice(1)];
var copy = {};
// Can't use _.extend({}, pieces) because es5-shim adds enumerable
// methods to Array.prototype, and _.extend has no own property check.
_.each(_.keys(pieces), key => copy[key] = pieces[key]);
return [copy, _.toArray(arguments).slice(1)];
};
const foo = 'B';
// uses `babelHelpers.taggedTemplateLiteralLoose`