From ca4724a0ac93faed4ea4a7f5853291a1a1710d16 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Fri, 16 Oct 2015 14:23:52 -0700 Subject: [PATCH] Do not configure compound property/attribute binding if literal if empty. Fixes #2583. --- src/lib/annotations/annotations.html | 4 ++-- src/standard/annotations.html | 7 +++---- test/unit/bind.html | 6 ++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib/annotations/annotations.html b/src/lib/annotations/annotations.html index 67db1f8ebc..fe03ea6531 100644 --- a/src/lib/annotations/annotations.html +++ b/src/lib/annotations/annotations.html @@ -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 diff --git a/src/standard/annotations.html b/src/standard/annotations.html index 1c498958a2..1deda3e0ca 100644 --- a/src/standard/annotations.html +++ b/src/standard/annotations.html @@ -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; } } } diff --git a/test/unit/bind.html b/test/unit/bind.html index 6aed2aab1a..842b0073df 100644 --- a/test/unit/bind.html +++ b/test/unit/bind.html @@ -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'); @@ -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';