From 77447c975cc957d25667b95b76a905bfe576e6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Tue, 22 Nov 2016 16:18:10 +0100 Subject: [PATCH] Stop relying on variable hoisting (#8380) Only declare the variable once in this scope, instead of declaring them multiple times in the same scope. This fixes #8318, even though it might technically be a shortcoming in Rollup. --- docs/js/react.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/js/react.js b/docs/js/react.js index 707e99a78201c9..dfdef9432a0bc8 100644 --- a/docs/js/react.js +++ b/docs/js/react.js @@ -1351,30 +1351,31 @@ typeof Set === 'function' && isNative(Set) && // Set.prototype.keys Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys); +var setItem, getItem, removeItem, getItemIDs, addRoot, removeRoot, getRootIDs; if (canUseCollections) { var itemMap = new Map(); var rootIDSet = new Set(); - var setItem = function (id, item) { + setItem = function (id, item) { itemMap.set(id, item); }; - var getItem = function (id) { + getItem = function (id) { return itemMap.get(id); }; - var removeItem = function (id) { + removeItem = function (id) { itemMap['delete'](id); }; - var getItemIDs = function () { + getItemIDs = function () { return Array.from(itemMap.keys()); }; - var addRoot = function (id) { + addRoot = function (id) { rootIDSet.add(id); }; - var removeRoot = function (id) { + removeRoot = function (id) { rootIDSet['delete'](id); }; - var getRootIDs = function () { + getRootIDs = function () { return Array.from(rootIDSet.keys()); }; } else { @@ -1390,31 +1391,31 @@ if (canUseCollections) { return parseInt(key.substr(1), 10); }; - var setItem = function (id, item) { + setItem = function (id, item) { var key = getKeyFromID(id); itemByKey[key] = item; }; - var getItem = function (id) { + getItem = function (id) { var key = getKeyFromID(id); return itemByKey[key]; }; - var removeItem = function (id) { + removeItem = function (id) { var key = getKeyFromID(id); delete itemByKey[key]; }; - var getItemIDs = function () { + getItemIDs = function () { return Object.keys(itemByKey).map(getIDFromKey); }; - var addRoot = function (id) { + addRoot = function (id) { var key = getKeyFromID(id); rootByKey[key] = true; }; - var removeRoot = function (id) { + removeRoot = function (id) { var key = getKeyFromID(id); delete rootByKey[key]; }; - var getRootIDs = function () { + getRootIDs = function () { return Object.keys(rootByKey).map(getIDFromKey); }; } @@ -3745,4 +3746,4 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) { }; },{}]},{},[18])(18) -}); \ No newline at end of file +});