Skip to content

Commit 7560130

Browse files
author
Steven Orvell
committed
Fix #2107: improve binding expression parser to match valid javascript property names.
1 parent 8134fbf commit 7560130

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/standard/effectBuilder.html‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@
168168

169169
// method expressions are of the form: `name([arg1, arg2, .... argn])`
170170
_parseMethod: function(expression) {
171-
var m = expression.match(/(\w*)\((.*)\)/);
171+
// tries to match valid javascript property names
172+
var m = expression.match(/([a-zA-Z_$][0-9a-zA-Z_$]*)\((.*)\)/);
172173
if (m) {
173174
var sig = { method: m[1], static: true };
174175
if (m[2].trim()) {

‎test/unit/bind-elements.html‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
custom-event-object-value="{{customEventObject.value::change}}"
1818
computed-from-mixed-literals='{{computeFromLiterals(3, "foo", bool)}}'
1919
computed-from-pure-literals='{{computeFromLiterals( 3, "foo")}}'
20+
computed-from-tricky-function='{{$computeTrickyFunctionFromLiterals( 3, "foo")}}'
2021
computed-from-tricky-literals="{{computeFromTrickyLiterals(3, 'tricky\,\'zot\'')}}"
2122
computed-from-tricky-literals2='{{computeFromTrickyLiterals(3,"tricky\,'zot'" )}}'
2223
computed-from-no-args="{{computeFromNoArgs( )}}"
@@ -223,6 +224,9 @@
223224
assert.equal(str, 'foo');
224225
return num + str;
225226
},
227+
$computeTrickyFunctionFromLiterals: function(num, str) {
228+
return this.computeFromLiterals(num, str);
229+
},
226230
computeFromTrickyLiterals: function(a, b) {
227231
return a + b;
228232
},

‎test/unit/bind.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
el.bool = true;
172172
assert.equal(el.$.boundChild.computedFromMixedLiterals, '3foo', 'Wrong result from mixed literal arg computation');
173173
assert.equal(el.$.boundChild.computedFromPureLiterals, '3foo', 'Wrong result from pure literal arg computation');
174+
assert.equal(el.$.boundChild.computedFromTrickyFunction, '3foo', 'Wrong result from tricky function with pure literal arg computation');
174175
assert.equal(el.$.boundChild.computedFromTrickyLiterals, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation');
175176
assert.equal(el.$.boundChild.computedFromTrickyLiterals2, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation');
176177
assert.equal(el.$.computedContent.textContent, '3tricky,\'zot\'', 'Wrong textContent from tricky literal arg computation');

0 commit comments

Comments
 (0)