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

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-selector/iron-multi-selectable-extracted.js

Issue 1766433002: Roll Polymer to 1.3.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
Index: third_party/polymer/v1_0/components-chromium/iron-selector/iron-multi-selectable-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-selector/iron-multi-selectable-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-selector/iron-multi-selectable-extracted.js
index 7c9c39ea3b72701d050c893a9218c8f899631a20..38b18a869f2887733b152d4bf346e0366b67cf21 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-selector/iron-multi-selectable-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-selector/iron-multi-selectable-extracted.js
@@ -32,7 +32,7 @@
},
observers: [
- '_updateSelected(attrForSelected, selectedValues)'
+ '_updateSelected(selectedValues)'
],
/**
@@ -63,6 +63,18 @@
(this.selectedValues != null && this.selectedValues.length);
},
+ _updateAttrForSelected: function() {
+ if (!this.multi) {
+ Polymer.IronSelectableBehavior._updateAttrForSelected.apply(this);
+ } else if (this._shouldUpdateSelection) {
+ this.selectedValues = this.selectedItems.map(function(selectedItem) {
+ return this._indexToValue(this.indexOf(selectedItem));
+ }, this).filter(function(unfilteredValue) {
+ return unfilteredValue != null;
+ }, this);
+ }
+ },
+
_updateSelected: function() {
if (this.multi) {
this._selectMulti(this.selectedValues);
@@ -72,11 +84,16 @@
},
_selectMulti: function(values) {
- this._selection.clear();
if (values) {
- for (var i = 0; i < values.length; i++) {
- this._selection.setItemSelected(this._valueToItem(values[i]), true);
+ var selectedItems = this._valuesToItems(values);
+ // clear all but the current selected items
+ this._selection.clear(selectedItems);
+ // select only those not selected yet
+ for (var i = 0; i < selectedItems.length; i++) {
+ this._selection.setItemSelected(selectedItems[i], true);
}
+ } else {
+ this._selection.clear();
}
},
@@ -99,6 +116,12 @@
this.splice('selectedValues',i,1);
}
this._selection.setItemSelected(this._valueToItem(value), unselected);
+ },
+
+ _valuesToItems: function(values) {
+ return (values == null) ? null : values.map(function(value) {
+ return this._valueToItem(value);
+ }, this);
}
};

Powered by Google App Engine
This is Rietveld 408576698