Skip to content

Commit

Permalink
Merge pull request #2109 from Polymer/fix-2107
Browse files Browse the repository at this point in the history
Fix #2107: improve binding expression parser to match valid javascrip…
  • Loading branch information
kevinpschaaf committed Jul 24, 2015
2 parents 2a51661 + 6cfa759 commit 7d72d7c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/standard/effectBuilder.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@

// method expressions are of the form: `name([arg1, arg2, .... argn])`
_parseMethod: function(expression) {
var m = expression.match(/(\w*)\((.*)\)/);
// tries to match valid javascript property names
var m = expression.match(/([^\s]+)\((.*)\)/);
if (m) {
var sig = { method: m[1], static: true };
if (m[2].trim()) {
Expand Down
4 changes: 4 additions & 0 deletions test/unit/bind-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
custom-event-object-value="{{customEventObject.value::change}}"
computed-from-mixed-literals='{{computeFromLiterals(3, "foo", bool)}}'
computed-from-pure-literals='{{computeFromLiterals( 3, "foo")}}'
computed-from-tricky-function='{{$computeTrickyFunctionFromLiterals( 3, "foo")}}'
computed-from-tricky-literals="{{computeFromTrickyLiterals(3, 'tricky\,\'zot\'')}}"
computed-from-tricky-literals2='{{computeFromTrickyLiterals(3,"tricky\,'zot'" )}}'
computed-from-no-args="{{computeFromNoArgs( )}}"
Expand Down Expand Up @@ -223,6 +224,9 @@
assert.equal(str, 'foo');
return num + str;
},
$computeTrickyFunctionFromLiterals: function(num, str) {
return this.computeFromLiterals(num, str);
},
computeFromTrickyLiterals: function(a, b) {
return a + b;
},
Expand Down
1 change: 1 addition & 0 deletions test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
el.bool = true;
assert.equal(el.$.boundChild.computedFromMixedLiterals, '3foo', 'Wrong result from mixed literal arg computation');
assert.equal(el.$.boundChild.computedFromPureLiterals, '3foo', 'Wrong result from 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.computedFromTrickyLiterals2, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation');
assert.equal(el.$.computedContent.textContent, '3tricky,\'zot\'', 'Wrong textContent from tricky literal arg computation');
Expand Down

0 comments on commit 7d72d7c

Please sign in to comment.