Fix compound bindings with braces in literals

This commit is contained in:
Tim van der Lippe 2015-11-09 18:00:52 +01:00
parent 07d39a1be8
commit 561b28b8bc
3 changed files with 8 additions and 1 deletions

View File

@ -88,7 +88,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this._parseElementAnnotations(node, list); this._parseElementAnnotations(node, list);
}, },
_bindingRegex: /([^{[]*)({{|\[\[)([^}\]]*)(?:]]|}})/g, _bindingRegex: /([^{[]*)(\{\{|\[\[)(?!\}\}|\]\])(.+?)(?:\]\]|\}\})/g,
// TODO(kschaaf): We could modify this to allow an escape mechanism by // TODO(kschaaf): We could modify this to allow an escape mechanism by
// looking for the escape sequence in each of the matches and converting // looking for the escape sequence in each of the matches and converting

View File

@ -26,6 +26,7 @@
no-computed="{{foobared(noInlineComputed)}}" no-computed="{{foobared(noInlineComputed)}}"
compoundAttr1$="{{cpnd1}}{{ cpnd2 }}{{cpnd3.prop}}{{ computeCompound(cpnd4, cpnd5, 'literal')}}" compoundAttr1$="{{cpnd1}}{{ cpnd2 }}{{cpnd3.prop}}{{ computeCompound(cpnd4, cpnd5, 'literal')}}"
compoundAttr2$="literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literal')}} literal4" compoundAttr2$="literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literal')}} literal4"
compoundAttr3$="{{computeCompound('world', 'username ', 'Hello {0} ')}}"
> >
Test Test
</div> </div>

View File

@ -767,6 +767,12 @@ suite('compound binding / string interpolation', function() {
assert.equal(el.$.boundChild.getAttribute('compoundAttr2'), 'literal1 literal2 literal3 literal literal4'); 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() { test('compound adjacent textNode bindings', function() {
var el = document.createElement('x-basic'); var el = document.createElement('x-basic');
// The single space is due to the gambit to prevent empty text nodes // The single space is due to the gambit to prevent empty text nodes