Skip to content

Commit

Permalink
Do not configure compound property/attribute binding if literal if em…
Browse files Browse the repository at this point in the history
…pty. Fixes #2583.
  • Loading branch information
kevinpschaaf committed Oct 16, 2015
1 parent 8080a30 commit ca4724a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/lib/annotations/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@
}
// Initialize attribute bindings with any literal parts
var literal = this._literalFromParts(parts);
if (kind == 'attribute') {
node.setAttribute(name, literal);
if (literal && kind == 'attribute') {
node.setAttribute(name, literal);
}
// Clear attribute before removing, since IE won't allow removing
// `value` attribute if it previously had a value (can't
Expand Down
7 changes: 3 additions & 4 deletions src/standard/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,11 @@
var name = binding.name;
storage[name] = literals;
// Configure properties with their literal parts
if (binding.kind == 'property') {
var literal = literals.join('');
if (binding.literal && binding.kind == 'property') {
if (node._configValue) {
node._configValue(name, literal);
node._configValue(name, binding.literal);
} else {
node[name] = literal;
node[name] = binding.literal;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@

test('compound adjacent property bindings', function() {
var el = document.createElement('x-basic');
assert.equal(el.$.boundProps.prop1, '');
// Adjacent compound binding with no literal do not override the default
assert.equal(el.$.boundProps.prop1, 'default');
assert.isTrue(el.$.boundProps.prop1Changed.calledOnce);
el.cpnd2 = 'cpnd2';
assert.equal(el.$.boundProps.prop1, 'cpnd2');
Expand Down Expand Up @@ -736,7 +737,8 @@

test('compound adjacent attribute bindings', function() {
var el = document.createElement('x-basic');
assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), '');
// Adjacent compound binding with no literal do not override the default
assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), null);
el.cpnd2 = 'cpnd2';
assert.equal(el.$.boundChild.getAttribute('compoundAttr1'), 'cpnd2');
el.cpnd1 = 'cpnd1';
Expand Down

0 comments on commit ca4724a

Please sign in to comment.