Skip to content

Commit

Permalink
Fixes #4478 by adding a better warning for attributes that cannot des…
Browse files Browse the repository at this point in the history
…erialize from JSON.
  • Loading branch information
Steven Orvell committed Apr 6, 2017
1 parent 7836e6c commit dba28c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mixins/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
outValue = JSON.parse(value);
} catch(x) {
outValue = null;
console.warn('Polymer::Attributes: couldn`t decode Array as JSON');
console.warn(`Polymer::Attributes: couldn't decode Array as JSON: ${value}`);
}
break;

Expand Down
9 changes: 9 additions & 0 deletions test/unit/attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@
assert.strictEqual(element.dashCase, 'Changed');
});

test('value that cannot deserialize from JSON warns', function() {
sinon.spy(console, 'warn');
var badAttr = '[foo, bar]';
element.setAttribute('array', badAttr);
assert.isTrue(console.warn.calledOnce);
assert.include(console.warn.firstCall.args[0], badAttr);
console.warn.restore();
});

});

suite('imperative attribute change (reflect)', function() {
Expand Down

0 comments on commit dba28c0

Please sign in to comment.