OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 Polymer({ | 5 Polymer({ |
6 is: 'bookmarks-list', | 6 is: 'bookmarks-list', |
7 | 7 |
8 behaviors: [ | 8 behaviors: [ |
9 bookmarks.StoreClient, | 9 bookmarks.StoreClient, |
10 ], | 10 ], |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 * focus on incremental update. | 66 * focus on incremental update. |
67 * @param {Array<string>} newValue | 67 * @param {Array<string>} newValue |
68 * @param {Array<string>} oldValue | 68 * @param {Array<string>} oldValue |
69 */ | 69 */ |
70 onDisplayedIdsChanged_: function(newValue, oldValue) { | 70 onDisplayedIdsChanged_: function(newValue, oldValue) { |
71 if (!oldValue) { | 71 if (!oldValue) { |
72 this.displayedList_ = this.displayedIds_.map(function(id) { | 72 this.displayedList_ = this.displayedIds_.map(function(id) { |
73 return {id: id}; | 73 return {id: id}; |
74 }); | 74 }); |
75 } else { | 75 } else { |
76 var splices = Polymer.ArraySplice.calculateSplices(newValue, oldValue); | 76 var splices = Polymer.ArraySplice.calculateSplices( |
| 77 /** @type {!Array<string>} */ (newValue), |
| 78 /** @type {!Array<string>} */ (oldValue)); |
77 splices.forEach(function(splice) { | 79 splices.forEach(function(splice) { |
78 // TODO(calamity): Could use notifySplices to improve performance here. | 80 // TODO(calamity): Could use notifySplices to improve performance here. |
79 var additions = | 81 var additions = |
80 newValue.slice(splice.index, splice.index + splice.addedCount) | 82 newValue.slice(splice.index, splice.index + splice.addedCount) |
81 .map(function(id) { | 83 .map(function(id) { |
82 return {id: id}; | 84 return {id: id}; |
83 }); | 85 }); |
84 this.splice.apply(this, [ | 86 this.splice.apply(this, [ |
85 'displayedList_', splice.index, splice.removed.length | 87 'displayedList_', splice.index, splice.removed.length |
86 ].concat(additions)); | 88 ].concat(additions)); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 176 |
175 this.dispatch(bookmarks.actions.selectItem( | 177 this.dispatch(bookmarks.actions.selectItem( |
176 this.displayedIds_[focusedIndex], this.getState(), config)); | 178 this.displayedIds_[focusedIndex], this.getState(), config)); |
177 } | 179 } |
178 } | 180 } |
179 | 181 |
180 if (handled) | 182 if (handled) |
181 e.stopPropagation(); | 183 e.stopPropagation(); |
182 }, | 184 }, |
183 }); | 185 }); |
OLD | NEW |