update components

This commit is contained in:
Luke Pulverenti 2016-04-08 23:08:50 -04:00
parent d9299a0a48
commit 101944aab9
36 changed files with 240 additions and 66 deletions

View file

@ -1,4 +1,5 @@
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
@ -113,6 +114,15 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
value: null
},
/**
* 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.
*/
@ -143,7 +153,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
observers: [
'_updateAttrForSelected(attrForSelected)',
'_updateSelected(selected)'
'_updateSelected(selected)',
'_checkFallback(fallbackSelection)'
],
created: function() {
@ -229,6 +240,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
return this.selected != null;
},
_checkFallback: function() {
if (this._shouldUpdateSelection) {
this._updateSelected();
}
},
_addListener: function(eventName) {
this.listen(this, eventName, '_activateHandler');
},
@ -250,7 +267,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_updateAttrForSelected: function() {
if (this._shouldUpdateSelection) {
this.selected = this._indexToValue(this.indexOf(this.selectedItem));
this.selected = this._indexToValue(this.indexOf(this.selectedItem));
}
},
@ -260,6 +277,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
_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) {