Chromium Code Reviews| Index: chrome/browser/resources/md_bookmarks/list.js |
| diff --git a/chrome/browser/resources/md_bookmarks/list.js b/chrome/browser/resources/md_bookmarks/list.js |
| index 365487a55254e8aa6b0366b8384f00ed68f0fa64..04169ea8ae6cb7ead95c82c388245803b57a28be 100644 |
| --- a/chrome/browser/resources/md_bookmarks/list.js |
| +++ b/chrome/browser/resources/md_bookmarks/list.js |
| @@ -10,16 +10,22 @@ Polymer({ |
| ], |
| properties: { |
| - /** @private {Array<string>} */ |
| + /** @private {Array<{id: string}>} */ |
| displayedList_: { |
| type: Array, |
| + // Use an empty list during initialization so that the databinding to |
| + // hide #bookmarksCard takes effect. |
| value: function() { |
| - // Use an empty list during initialization so that the databinding to |
| - // hide #bookmarksCard takes effect. |
| return []; |
| }, |
| }, |
| + /** @private {Array<string>} */ |
| + displayedIds_: { |
| + type: Array, |
| + observer: 'onDisplayedIdsChanged_', |
| + }, |
| + |
| /** @private */ |
| searchTerm_: String, |
| }, |
| @@ -29,7 +35,10 @@ Polymer({ |
| }, |
| attached: function() { |
| - this.watch('displayedList_', function(state) { |
| + var list = /** @type {IronListElement} */ (this.$.bookmarksCard); |
| + list.scrollTarget = this; |
| + |
| + this.watch('displayedIds_', function(state) { |
| return bookmarks.util.getDisplayedList(state); |
| }); |
| this.watch('searchTerm_', function(state) { |
| @@ -42,6 +51,27 @@ Polymer({ |
| return this.$.message; |
| }, |
| + onDisplayedIdsChanged_: function(newValue, oldValue) { |
|
tsergeant
2017/05/16 03:41:51
Comment here with why all this is necessary/useful
calamity
2017/05/17 03:28:27
Done.
|
| + if (!oldValue) { |
| + this.displayedList_ = this.displayedIds_.map(function(id) { |
| + return {id: id}; |
| + }); |
| + } else { |
| + var splices = Polymer.ArraySplice.calculateSplices(newValue, oldValue); |
| + splices.forEach(function(splice) { |
| + // TODO(calamity): Could use notifySplices to improve performance here. |
| + var additions = |
| + newValue.slice(splice.index, splice.index + splice.addedCount) |
| + .map(function(id) { |
| + return {id: id}; |
| + }); |
| + this.splice( |
| + 'displayedList_', splice.index, splice.removed.length, |
| + ...additions); |
|
tsergeant
2017/05/16 03:41:51
Check if uglify errors when parsing this file (I s
calamity
2017/05/17 03:28:27
Done.
|
| + }.bind(this)); |
| + } |
| + }, |
| + |
| /** @private */ |
| emptyListMessage_: function() { |
| var emptyListMessage = this.searchTerm_ ? 'noSearchResults' : 'emptyList'; |