diff --git a/paper-radio-group.html b/paper-radio-group.html
index 93ac1ac..7e4989d 100644
--- a/paper-radio-group.html
+++ b/paper-radio-group.html
@@ -132,24 +132,27 @@
return;
}
- if (this.selected) {
+ if ( (this.selected !== undefined) && (this.selected !== null)) {
var oldItem = this._valueToItem(this.selected);
- if (this.selected == value) {
+ if (this.selected === value) {
// If deselecting is allowed we'll have to apply an empty selection.
// Otherwise, we should force the selection to stay and make this
// action a no-op.
if (this.allowEmptySelection) {
value = '';
} else {
- if (oldItem)
+ if (oldItem) {
oldItem.checked = true;
+ }
+
return;
}
}
- if (oldItem)
+ if (oldItem) {
oldItem.checked = false;
+ }
}
Polymer.IronSelectableBehavior.select.apply(this, [value]);
diff --git a/test/basic.html b/test/basic.html
index ab798cd..b8df876 100644
--- a/test/basic.html
+++ b/test/basic.html
@@ -42,6 +42,15 @@
+
+
+
+ No
+ Yes
+
+
+
+
@@ -192,6 +201,28 @@
}, 1);
});
+ test('clicking the selected item should not deselect with falsy values', function (done) {
+ var g = fixture('WithFalsyValueSelection');
+ MockInteractions.focus(g);
+
+ // Needs to be async since the underlying iron-selector uses observeNodes.
+ Polymer.Base.async(function() {
+ var items = g.items;
+
+ expect(items[0].checked).to.be.equal(true);
+
+ // The selection should not change, but wait for a little bit just
+ // in case it would and an event would be fired.
+ setTimeout(function() {
+ expect(items[0].checked).to.be.equal(true);
+ expect(items[1].checked).to.be.equal(false);
+ done();
+ }, 1);
+
+ MockInteractions.tap(items[0]);
+ }, 1);
+ });
+
test('clicking the selected item should deselect if allow-empty-selection is set', function (done) {
var g = fixture('WithSelection');
g.allowEmptySelection = true;