Merge pull request #2486 from mgiuffrida/patch-1

Allow newlines in computed binding argument list
This commit is contained in:
Kevin Schaaf 2016-02-04 14:54:40 -08:00
commit 473a1ee717
3 changed files with 10 additions and 1 deletions

View File

@ -190,7 +190,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// method expressions are of the form: `name([arg1, arg2, .... argn])` // method expressions are of the form: `name([arg1, arg2, .... argn])`
_parseMethod: function(expression) { _parseMethod: function(expression) {
// tries to match valid javascript property names // tries to match valid javascript property names
var m = expression.match(/([^\s]+?)\((.*)\)/); var m = expression.match(/([^\s]+?)\(([\s\S]*)\)/);
if (m) { if (m) {
var sig = { method: m[1], static: true }; var sig = { method: m[1], static: true };
if (m[2].trim()) { if (m[2].trim()) {

View File

@ -9,7 +9,11 @@
camel-case="{{value}}" camel-case="{{value}}"
computed-inline="{{computeInline(value,add, divide)}}" computed-inline="{{computeInline(value,add, divide)}}"
computed-inline2="{{computeInline(value, add,divide)}}" computed-inline2="{{computeInline(value, add,divide)}}"
computed-inline3="{{computeInline(value, add,
divide)}}"
computedattribute$="{{computeInline(value, add,divide)}}" computedattribute$="{{computeInline(value, add,divide)}}"
computedattribute2$="{{computeInline(
value, add, divide)}}"
neg-computed-inline="{{!computeInline(value,add,divide)}}" neg-computed-inline="{{!computeInline(value,add,divide)}}"
computed-negative-number="{{computeNegativeNumber(-1)}}" computed-negative-number="{{computeNegativeNumber(-1)}}"
computed-negative-literal="{{computeNegativeNumber(-A)}}" computed-negative-literal="{{computeNegativeNumber(-A)}}"
@ -23,6 +27,8 @@
computed-from-tricky-function='{{$computeTrickyFunctionFromLiterals( 3, "foo")}}' computed-from-tricky-function='{{$computeTrickyFunctionFromLiterals( 3, "foo")}}'
computed-from-tricky-literals="{{computeFromTrickyLiterals(3, 'tricky\,\'zot\'')}}" computed-from-tricky-literals="{{computeFromTrickyLiterals(3, 'tricky\,\'zot\'')}}"
computed-from-tricky-literals2='{{computeFromTrickyLiterals(3,"tricky\,'zot'" )}}' computed-from-tricky-literals2='{{computeFromTrickyLiterals(3,"tricky\,'zot'" )}}'
computed-from-tricky-literals3='{{computeFromTrickyLiterals(3,
"tricky\,'zot'" )}}'
computed-from-no-args="{{computeFromNoArgs( )}}" computed-from-no-args="{{computeFromNoArgs( )}}"
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')}}"

View File

@ -173,6 +173,7 @@ suite('single-element binding effects', function() {
assert.equal(el.$.boundChild.computedFromTrickyFunction, '3foo', 'Wrong result from tricky function with pure literal arg computation'); assert.equal(el.$.boundChild.computedFromTrickyFunction, '3foo', 'Wrong result from tricky function with pure literal arg computation');
assert.equal(el.$.boundChild.computedFromTrickyLiterals, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation'); assert.equal(el.$.boundChild.computedFromTrickyLiterals, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation');
assert.equal(el.$.boundChild.computedFromTrickyLiterals2, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation'); assert.equal(el.$.boundChild.computedFromTrickyLiterals2, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation');
assert.equal(el.$.boundChild.computedFromTrickyLiterals3, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation');
assert.equal(el.$.computedContent.textContent, '3tricky,\'zot\'', 'Wrong textContent from tricky literal arg computation'); assert.equal(el.$.computedContent.textContent, '3tricky,\'zot\'', 'Wrong textContent from tricky literal arg computation');
assert.equal(el.$.computedContent2.textContent, '(3', 'Wrong textContent from tricky literal arg computation'); assert.equal(el.$.computedContent2.textContent, '(3', 'Wrong textContent from tricky literal arg computation');
}); });
@ -224,6 +225,7 @@ suite('single-element binding effects', function() {
el.divide = 3; el.divide = 3;
assert.equal(el.$.boundChild.computedInline, 20, 'computedInline not correct'); assert.equal(el.$.boundChild.computedInline, 20, 'computedInline not correct');
assert.equal(el.$.boundChild.computedInline2, 20, 'computedInline2 not correct'); assert.equal(el.$.boundChild.computedInline2, 20, 'computedInline2 not correct');
assert.equal(el.$.boundChild.computedInline3, 20, 'computedInline3 not correct');
assert.equal(el.$.boundChild.negComputedInline, false, 'negComputedInline not correct'); assert.equal(el.$.boundChild.negComputedInline, false, 'negComputedInline not correct');
}); });
@ -232,6 +234,7 @@ suite('single-element binding effects', function() {
el.add = 40; el.add = 40;
el.divide = 3; el.divide = 3;
assert.equal(el.$.boundChild.getAttribute('computedattribute'), 20, 'computed attribute not correct'); assert.equal(el.$.boundChild.getAttribute('computedattribute'), 20, 'computed attribute not correct');
assert.equal(el.$.boundChild.getAttribute('computedattribute2'), 20, 'computed attribute not correct');
}); });
test('annotated style attribute binding', function() { test('annotated style attribute binding', function() {