From b81c0880dad3bcd7d313a40049fe3009babc3fb9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 21 Jun 2015 16:33:28 -0700 Subject: [PATCH] Rearranging some of the Map/Set runtime shim clobberings to be more efficient. --- es6-shim.js | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/es6-shim.js b/es6-shim.js index ead66945..37ab863e 100644 --- a/es6-shim.js +++ b/es6-shim.js @@ -2618,7 +2618,6 @@ return SetShim; }()) }; - defineProperties(globals, collectionShims); if (globals.Map || globals.Set) { // Safari 8, for example, doesn't accept an iterable. @@ -2790,25 +2789,28 @@ Set: collectionShims.Set }, true); } + + if (globals.Set.prototype.keys !== globals.Set.prototype.values) { + // Fixed in WebKit with https://bugs.webkit.org/show_bug.cgi?id=144190 + defineProperty(globals.Set.prototype, 'keys', globals.Set.prototype.values, true); + } + + // Shim incomplete iterator implementations. + addIterator(Object.getPrototypeOf((new globals.Map()).keys())); + addIterator(Object.getPrototypeOf((new globals.Set()).keys())); + + if (functionsHaveNames && globals.Set.prototype.has.name !== 'has') { + // Microsoft Edge v0.11.10074.0 is missing a name on Set#has + var anonymousSetHas = globals.Set.prototype.has; + overrideNative(globals.Set.prototype, 'has', function has(key) { + return _call(anonymousSetHas, this, key); + }); + } } - if (globals.Set.prototype.keys !== globals.Set.prototype.values) { - // Fixed in WebKit with https://bugs.webkit.org/show_bug.cgi?id=144190 - defineProperty(globals.Set.prototype, 'keys', globals.Set.prototype.values, true); - } - // Shim incomplete iterator implementations. - addIterator(Object.getPrototypeOf((new globals.Map()).keys())); - addIterator(Object.getPrototypeOf((new globals.Set()).keys())); - - if (functionsHaveNames && globals.Set.prototype.has.name !== 'has') { - // Microsoft Edge v0.11.10074.0 is missing a name on Set#has - var anonymousSetHas = globals.Set.prototype.has; - overrideNative(globals.Set.prototype, 'has', function has(key) { - return _call(anonymousSetHas, this, key); - }); - } + defineProperties(globals, collectionShims); + addDefaultSpecies(globals.Map); + addDefaultSpecies(globals.Set); } - addDefaultSpecies(Map); - addDefaultSpecies(Set); // Reflect if (!globals.Reflect) {