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

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

Issue 1862213002: Roll third_party/polymer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete appearance_browsertest.js, result of a previous bad merge. Created 4 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
Index: third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js
index 291e7de4c4758e36029e74eda4d0d0c39eabbc7e..2dcc7b2e6950811a90c83ab279d4ff8d4f8dcd30 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-selector/iron-selectable-extracted.js
@@ -32,8 +32,14 @@
properties: {
/**
- * If you want to use the attribute value of an element for `selected` instead of the index,
- * set this to the name of the attribute.
+ * If you want to use an attribute value or property of an element for
+ * `selected` instead of the index, set this to the name of the attribute
+ * or property. Hyphenated values are converted to camel case when used to
+ * look up the property of a selectable element. Camel cased values are
+ * *not* converted to hyphenated values for attribute lookup. It's
+ * recommended that you provide the hyphenated form of the name so that
+ * selection works in both cases. (Use `attr-or-property-name` instead of
+ * `attrOrPropertyName`.)
*/
attrForSelected: {
type: String,
@@ -94,6 +100,15 @@
},
/**
+ * Default fallback if the selection based on selected with `attrForSelected`
+ * is not found.
+ */
+ fallbackSelection: {
+ type: String,
+ value: null
+ },
+
+ /**
* The list of items from which a selection can be made.
*/
items: {
@@ -123,7 +138,8 @@
observers: [
'_updateAttrForSelected(attrForSelected)',
- '_updateSelected(selected)'
+ '_updateSelected(selected)',
+ '_checkFallback(fallbackSelection)'
],
created: function() {
@@ -209,6 +225,12 @@
return this.selected != null;
},
+ _checkFallback: function() {
+ if (this._shouldUpdateSelection) {
+ this._updateSelected();
+ }
+ },
+
_addListener: function(eventName) {
this.listen(this, eventName, '_activateHandler');
},
@@ -230,7 +252,7 @@
_updateAttrForSelected: function() {
if (this._shouldUpdateSelection) {
- this.selected = this._indexToValue(this.indexOf(this.selectedItem));
+ this.selected = this._indexToValue(this.indexOf(this.selectedItem));
}
},
@@ -240,6 +262,11 @@
_selectSelected: function(selected) {
this._selection.select(this._valueToItem(this.selected));
+ // Check for items, since this array is populated only when attached
+ // Since Number(0) is falsy, explicitly check for undefined
+ if (this.fallbackSelection && this.items.length && (this._selection.get() === undefined)) {
+ this.selected = this.fallbackSelection;
+ }
},
_filterItem: function(node) {
@@ -274,7 +301,7 @@
},
_valueForItem: function(item) {
- var propValue = item[this.attrForSelected];
+ var propValue = item[Polymer.CaseMap.dashToCamelCase(this.attrForSelected)];
return propValue != undefined ? propValue : item.getAttribute(this.attrForSelected);
},

Powered by Google App Engine
This is Rietveld 408576698