Chromium Code Reviews| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 | 54 |
| 55 /** @return {HTMLElement} */ | 55 /** @return {HTMLElement} */ |
| 56 getDropTarget: function() { | 56 getDropTarget: function() { |
| 57 return this.$.message; | 57 return this.$.message; |
| 58 }, | 58 }, |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * Updates `displayedList_` using splices to be equivalent to `newValue`. This | 61 * Updates `displayedList_` using splices to be equivalent to `newValue`. This |
| 62 * allows the iron-list to delete sublists of items which preserves scroll and | 62 * allows the iron-list to delete sublists of items which preserves scroll and |
| 63 * focus on incremental update. | 63 * focus on incremental update. |
| 64 * @param {Array<string>} newValue | 64 * @param {!Array<string>} newValue |
| 65 * @param {Array<string>} oldValue | 65 * @param {!Array<string>} oldValue |
| 66 */ | 66 */ |
| 67 onDisplayedIdsChanged_: function(newValue, oldValue) { | 67 onDisplayedIdsChanged_: function(newValue, oldValue) { |
| 68 if (!oldValue) { | 68 if (!oldValue) { |
|
Dan Beam
2017/05/24 02:52:42
hmmmm, how can !oldValue ever succeed if oldValue
dpapad
2017/05/24 17:45:42
The problem is that calculateSplices() has two dif
scottchen
2017/05/24 20:36:25
Done.
scottchen
2017/05/24 20:36:25
Acknowledged.
| |
| 69 this.displayedList_ = this.displayedIds_.map(function(id) { | 69 this.displayedList_ = this.displayedIds_.map(function(id) { |
| 70 return {id: id}; | 70 return {id: id}; |
| 71 }); | 71 }); |
| 72 } else { | 72 } else { |
| 73 var splices = Polymer.ArraySplice.calculateSplices(newValue, oldValue); | 73 var splices = Polymer.ArraySplice.calculateSplices(newValue, oldValue); |
| 74 splices.forEach(function(splice) { | 74 splices.forEach(function(splice) { |
| 75 // TODO(calamity): Could use notifySplices to improve performance here. | 75 // TODO(calamity): Could use notifySplices to improve performance here. |
| 76 var additions = | 76 var additions = |
| 77 newValue.slice(splice.index, splice.index + splice.addedCount) | 77 newValue.slice(splice.index, splice.index + splice.addedCount) |
| 78 .map(function(id) { | 78 .map(function(id) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 94 /** @private */ | 94 /** @private */ |
| 95 isEmptyList_: function() { | 95 isEmptyList_: function() { |
| 96 return this.displayedList_.length == 0; | 96 return this.displayedList_.length == 0; |
| 97 }, | 97 }, |
| 98 | 98 |
| 99 /** @private */ | 99 /** @private */ |
| 100 deselectItems_: function() { | 100 deselectItems_: function() { |
| 101 this.dispatch(bookmarks.actions.deselectItems()); | 101 this.dispatch(bookmarks.actions.deselectItems()); |
| 102 }, | 102 }, |
| 103 }); | 103 }); |
| OLD | NEW |