Skip to content

Commit ba4bf38

Browse files
committed
Use multi-prop observer; default selected to null.
1 parent 5bca55b commit ba4bf38

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎src/lib/template/array-selector.html‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
*/
7575
items: {
7676
type: Array,
77-
observer: '_resetSelection'
77+
notify: true
7878
},
7979

8080
/**
@@ -100,11 +100,15 @@
100100
*/
101101
multi: {
102102
type: Boolean,
103-
observer: '_resetSelection'
103+
value: false
104104
}
105105
},
106106

107-
_resetSelection: function() {
107+
observers: [
108+
'_resetSelection(items, multi)'
109+
],
110+
111+
_resetSelection: function(items, multi) {
108112
// Unbind previous selection
109113
if (Array.isArray(this.selected)) {
110114
for (var i=0; i<this.selected.length; i++) {
@@ -114,7 +118,7 @@
114118
this.unlinkPaths('selected');
115119
}
116120
// Initialize selection
117-
if (this.multi) {
121+
if (multi && items) {
118122
this.selected = [];
119123
} else {
120124
this.selected = null;

‎test/unit/array-selector.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
test('bound defaults', function() {
8484
assert.equal(bind.$.observer.singleSelected, null);
85-
assert.sameMembers(bind.$.observer.multiSelected, []);
85+
assert.equal(bind.$.observer.multiSelected, null);
8686
bind.items = [
8787
{name: 'one'},
8888
{name: 'two'},

0 commit comments

Comments
 (0)