Skip to content
Browse files

Use multi-prop observer; default selected to null.

  • Loading branch information...
1 parent 5bca55b commit ba4bf382b1b01dd68ba50804f06e20797fa78883 @kevinpschaaf kevinpschaaf committed
Showing with 9 additions and 5 deletions.
  1. +8 −4 src/lib/template/array-selector.html
  2. +1 −1 test/unit/array-selector.html
View
12 src/lib/template/array-selector.html
@@ -74,7 +74,7 @@
*/
items: {
type: Array,
- observer: '_resetSelection'
+ notify: true
},
/**
@@ -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++) {
@@ -114,7 +118,7 @@
this.unlinkPaths('selected');
}
// Initialize selection
- if (this.multi) {
+ if (multi && items) {
this.selected = [];
} else {
this.selected = null;
View
2 test/unit/array-selector.html
@@ -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'},

0 comments on commit ba4bf38

Please sign in to comment.
Something went wrong with that request. Please try again.