Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: chrome/browser/resources/md_bookmarks/reducers.js

Issue 2774233006: [MD Bookmarks] Change selection items from Map to Set. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/md_bookmarks/item.js ('k') | chrome/browser/resources/md_bookmarks/types.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_bookmarks/reducers.js
diff --git a/chrome/browser/resources/md_bookmarks/reducers.js b/chrome/browser/resources/md_bookmarks/reducers.js
index be72c3ac15cc7dc9c4f0f7065dff809640f0d9a6..959949c422cd57733f19f716c189a1b485e34891 100644
--- a/chrome/browser/resources/md_bookmarks/reducers.js
+++ b/chrome/browser/resources/md_bookmarks/reducers.js
@@ -18,12 +18,12 @@ cr.define('bookmarks', function() {
* @return {SelectionState}
*/
SelectionState.selectItems = function(selectionState, action) {
- var newItems = {};
+ var newItems = new Set();
if (action.add)
- Object.assign(newItems, selectionState.items);
+ newItems = new Set(selectionState.items);
action.items.forEach(function(id) {
- newItems[id] = true;
+ newItems.add(id);
});
return /** @type {SelectionState} */ (Object.assign({}, selectionState, {
@@ -38,7 +38,7 @@ cr.define('bookmarks', function() {
*/
SelectionState.deselectAll = function(selectionState) {
return {
- items: {},
+ items: new Set(),
anchor: null,
};
};
@@ -274,16 +274,16 @@ cr.define('bookmarks', function() {
*/
ClosedFolderState.openFolderAndAncestors = function(
closedFolders, id, nodes) {
- var modifications = {};
+ var newClosedFolders = new Set(closedFolders);
var currentId = id;
while (currentId) {
- if (closedFolders[currentId])
- modifications[currentId] = false;
+ if (closedFolders.has(currentId))
+ newClosedFolders.delete(currentId);
currentId = nodes[currentId].parentId;
}
- return Object.assign({}, closedFolders, modifications);
+ return newClosedFolders;
};
/**
@@ -293,10 +293,13 @@ cr.define('bookmarks', function() {
*/
ClosedFolderState.changeFolderOpen = function(closedFolders, action) {
var closed = !action.open;
- var modification = {};
- modification[action.id] = closed;
+ var newClosedFolders = new Set(closedFolders);
+ if (closed)
+ newClosedFolders.add(action.id);
+ else
+ newClosedFolders.delete(action.id);
- return Object.assign({}, closedFolders, modification);
+ return newClosedFolders;
};
/**
« no previous file with comments | « chrome/browser/resources/md_bookmarks/item.js ('k') | chrome/browser/resources/md_bookmarks/types.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698