@samitouri / QOS-React / commits / f686218268

Revert "Stop relying on variable hoisting" (#8381)

Dan Abramov committed Nov 22, 2016 at 15:19 UTC f686218268ec7a0fb46c86b2fea99ce0f2644f10
1 file changed +15 -16
docs/js/react.js
+15 -16
@@ -1351,31 +1351,30 @@ typeof Set === 'function' && isNative(Set) &&
1351 // Set.prototype.keys
1352 Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys);
1353
1354 -var setItem, getItem, removeItem, getItemIDs, addRoot, removeRoot, getRootIDs;
1354 if (canUseCollections) {
1355 var itemMap = new Map();
1356 var rootIDSet = new Set();
1357
1359 - setItem = function (id, item) {
1358 + var setItem = function (id, item) {
1359 itemMap.set(id, item);
1360 };
1362 - getItem = function (id) {
1361 + var getItem = function (id) {
1362 return itemMap.get(id);
1363 };
1365 - removeItem = function (id) {
1364 + var removeItem = function (id) {
1365 itemMap['delete'](id);
1366 };
1368 - getItemIDs = function () {
1367 + var getItemIDs = function () {
1368 return Array.from(itemMap.keys());
1369 };
1370
1372 - addRoot = function (id) {
1371 + var addRoot = function (id) {
1372 rootIDSet.add(id);
1373 };
1375 - removeRoot = function (id) {
1374 + var removeRoot = function (id) {
1375 rootIDSet['delete'](id);
1376 };
1378 - getRootIDs = function () {
1377 + var getRootIDs = function () {
1378 return Array.from(rootIDSet.keys());
1379 };
1380 } else {
@@ -1391,31 +1390,31 @@ if (canUseCollections) {
1390 return parseInt(key.substr(1), 10);
1391 };
1392
1394 - setItem = function (id, item) {
1393 + var setItem = function (id, item) {
1394 var key = getKeyFromID(id);
1395 itemByKey[key] = item;
1396 };
1398 - getItem = function (id) {
1397 + var getItem = function (id) {
1398 var key = getKeyFromID(id);
1399 return itemByKey[key];
1400 };
1402 - removeItem = function (id) {
1401 + var removeItem = function (id) {
1402 var key = getKeyFromID(id);
1403 delete itemByKey[key];
1404 };
1406 - getItemIDs = function () {
1405 + var getItemIDs = function () {
1406 return Object.keys(itemByKey).map(getIDFromKey);
1407 };
1408
1410 - addRoot = function (id) {
1409 + var addRoot = function (id) {
1410 var key = getKeyFromID(id);
1411 rootByKey[key] = true;
1412 };
1414 - removeRoot = function (id) {
1413 + var removeRoot = function (id) {
1414 var key = getKeyFromID(id);
1415 delete rootByKey[key];
1416 };
1418 - getRootIDs = function () {
1417 + var getRootIDs = function () {
1418 return Object.keys(rootByKey).map(getIDFromKey);
1419 };
1420 }
@@ -3746,4 +3745,4 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) {
3745 };
3746
3747 },{}]},{},[18])(18)
3749 -});
3748 +});
\ No newline at end of file