Skip to content

Commit

Permalink
Use multi-prop observer; default selected to null.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Aug 7, 2015
1 parent 5bca55b commit ba4bf38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/lib/template/array-selector.html
Expand Up @@ -74,7 +74,7 @@
*/
items: {
type: Array,
observer: '_resetSelection'
notify: true
},

/**
Expand All @@ -100,11 +100,15 @@
*/
multi: {
type: Boolean,
observer: '_resetSelection'
value: false
}
},

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

_resetSelection: function(items, multi) {
// Unbind previous selection
if (Array.isArray(this.selected)) {
for (var i=0; i<this.selected.length; i++) {
Expand All @@ -114,7 +118,7 @@
this.unlinkPaths('selected');
}
// Initialize selection
if (this.multi) {
if (multi && items) {
this.selected = [];
} else {
this.selected = null;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/array-selector.html
Expand Up @@ -82,7 +82,7 @@

test('bound defaults', function() {
assert.equal(bind.$.observer.singleSelected, null);
assert.sameMembers(bind.$.observer.multiSelected, []);
assert.equal(bind.$.observer.multiSelected, null);
bind.items = [
{name: 'one'},
{name: 'two'},
Expand Down

0 comments on commit ba4bf38

Please sign in to comment.