Skip to content

Commit

Permalink
Make _itemsChanged depend on multi.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Aug 6, 2015
1 parent 0892e93 commit 1b21397
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/lib/template/array-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
* An array containing items from which selection will be made.
*/
items: {
type: Array,
observer: '_itemsChanged'
type: Array
},

/**
Expand All @@ -98,10 +97,17 @@
* `selected` is an array of currently selected items). When `false`,
* only one item may be selected at a time.
*/
multi: Boolean
multi: {
type: Boolean,
value: false
}
},

_itemsChanged: function() {
observers: [
'_itemsChanged(items, multi)'
],

_itemsChanged: function(items, multi) {
// Unbind previous selection
if (Array.isArray(this.selected)) {
for (var i=0; i<this.selected.length; i++) {
Expand All @@ -111,7 +117,7 @@
this.unlinkPaths('selected');
}
// Initialize selection
if (this.multi) {
if (multi) {
this.selected = [];
} else {
this.selected = null;
Expand Down Expand Up @@ -151,8 +157,7 @@
// var sidx = this.selected.indexOf(item);
// if (sidx < 0) {
var scol = Polymer.Collection.get(this.selected);
var skey = scol.getKey(item);
if (skey >= 0) {
if (scol.getKey(item) !== undefined) {
if (this.toggle) {
this.deselect(item);
}
Expand Down

0 comments on commit 1b21397

Please sign in to comment.