From ba0aa4d7099d05dcd54829c9104d9294bc2feca6 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Fri, 24 Jul 2015 16:54:11 -0400 Subject: [PATCH] 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. --- packages/ecmascript/runtime-tests.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/ecmascript/runtime-tests.js b/packages/ecmascript/runtime-tests.js index ff8d2b2956..110e4218a4 100644 --- a/packages/ecmascript/runtime-tests.js +++ b/packages/ecmascript/runtime-tests.js @@ -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`