Skip to content

Commit

Permalink
Fix compound bindings with braces in literals
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Nov 9, 2015
1 parent 07d39a1 commit 561b28b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/annotations/annotations.html
Expand Up @@ -88,7 +88,7 @@
this._parseElementAnnotations(node, list);
},

_bindingRegex: /([^{[]*)({{|\[\[)([^}\]]*)(?:]]|}})/g,
_bindingRegex: /([^{[]*)(\{\{|\[\[)(?!\}\}|\]\])(.+?)(?:\]\]|\}\})/g,

// TODO(kschaaf): We could modify this to allow an escape mechanism by
// looking for the escape sequence in each of the matches and converting
Expand Down
1 change: 1 addition & 0 deletions test/unit/bind-elements.html
Expand Up @@ -26,6 +26,7 @@
no-computed="{{foobared(noInlineComputed)}}"
compoundAttr1$="{{cpnd1}}{{ cpnd2 }}{{cpnd3.prop}}{{ computeCompound(cpnd4, cpnd5, 'literal')}}"
compoundAttr2$="literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literal')}} literal4"
compoundAttr3$="{{computeCompound('world', 'username ', 'Hello {0} ')}}"
>
Test
</div>
Expand Down
6 changes: 6 additions & 0 deletions test/unit/bind.html
Expand Up @@ -767,6 +767,12 @@
assert.equal(el.$.boundChild.getAttribute('compoundAttr2'), 'literal1 literal2 literal3 literal literal4');
});

test('compound property attribute with {} in text', function() {
var el = document.createElement('x-basic');

assert.equal(el.$.boundChild.getAttribute('compoundAttr3'), 'Hello {0} username world')
})

test('compound adjacent textNode bindings', function() {
var el = document.createElement('x-basic');
// The single space is due to the gambit to prevent empty text nodes
Expand Down

0 comments on commit 561b28b

Please sign in to comment.