Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update items when selectable changes, test provided, closes #126 #127

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion iron-selectable.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@
* This is a CSS selector string. If this is set, only items that match the CSS selector
* are selectable.
*/
selectable: String,
selectable: {
type: String,
observer: '_selectableChanged'
},

/**
* The class to set on elements when selected.
Expand Down Expand Up @@ -268,6 +271,13 @@
this._addListener(eventName);
},

_selectableChanged: function() {
this._updateItems();
if (this._shouldUpdateSelection) {
this._updateSelected();
}
},

_updateItems: function() {
var nodes = Polymer.dom(this).queryDistributedElements(this.selectable || '*');
nodes = Array.prototype.filter.call(nodes, this._bindFilterItem);
Expand Down
12 changes: 12 additions & 0 deletions test/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@
assert.isTrue(s2.querySelector('#item4').classList.contains('iron-selected'));
});

test('selectable property changes', function() {
s2.selectable = 'hr';
// check items length
assert.equal(s2.$.selector.items.length, 2);

s2.selectable = 'item';
s2.selected = 'item4';
// check items length
assert.equal(s2.$.selector.items.length, 5);
// check selected class
assert.isTrue(s2.querySelector('#item4').classList.contains('iron-selected'));
});
});

suite('content with dom-repeat', function() {
Expand Down