From b745f45e1f507b6918011dad59247fb5f15c3c8f Mon Sep 17 00:00:00 2001 From: Michael Giuffrida Date: Sat, 26 Sep 2015 15:20:28 -0700 Subject: [PATCH 1/3] Allow newlines in computed binding argument list This allows breaking in the middle of computed bindings, e.g.: ```
``` Note that `[\s\S]*` [doesn't seem to have worse performance]( http://jsperf.com/javascript-multiline-regexp-workarounds/5) than `.*`. --- src/standard/effectBuilder.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/standard/effectBuilder.html b/src/standard/effectBuilder.html index 4048a0ca..85400713 100644 --- a/src/standard/effectBuilder.html +++ b/src/standard/effectBuilder.html @@ -169,7 +169,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])` _parseMethod: function(expression) { // tries to match valid javascript property names - var m = expression.match(/([^\s]+)\((.*)\)/); + var m = expression.match(/([^\s]+)\(([\s\S]*)\)/); if (m) { var sig = { method: m[1], static: true }; if (m[2].trim()) { From de371bb472411c04ffd417fa62a1f59633a365fc Mon Sep 17 00:00:00 2001 From: Michael Giuffrida Date: Sat, 26 Sep 2015 18:12:00 -0700 Subject: [PATCH 2/3] Unit tests --- test/unit/bind-elements.html | 6 ++++++ test/unit/bind.html | 3 +++ 2 files changed, 9 insertions(+) diff --git a/test/unit/bind-elements.html b/test/unit/bind-elements.html index 250feae7..06fd7de9 100644 --- a/test/unit/bind-elements.html +++ b/test/unit/bind-elements.html @@ -9,7 +9,11 @@ camel-case="{{value}}" computed-inline="{{computeInline(value,add, divide)}}" computed-inline2="{{computeInline(value, add,divide)}}" + computed-inline3="{{computeInline(value, add, + divide)}}" computedattribute$="{{computeInline(value, add,divide)}}" + computedattribute2$="{{computeInline( + value, add, divide)}}" neg-computed-inline="{{!computeInline(value,add,divide)}}" computed-negative-number="{{computeNegativeNumber(-1)}}" computed-negative-literal="{{computeNegativeNumber(-A)}}" @@ -22,6 +26,8 @@ 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-tricky-literals3='{{computeFromTrickyLiterals(3, + "tricky\,'zot'" )}}' computed-from-no-args="{{computeFromNoArgs( )}}" no-computed="{{foobared(noInlineComputed)}}" > diff --git a/test/unit/bind.html b/test/unit/bind.html index 3a003841..47d7d889 100644 --- a/test/unit/bind.html +++ b/test/unit/bind.html @@ -174,6 +174,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.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.computedFromTrickyLiterals3, '3tricky,\'zot\'', 'Wrong result from tricky literal arg computation'); assert.equal(el.$.computedContent.textContent, '3tricky,\'zot\'', 'Wrong textContent from tricky literal arg computation'); }); @@ -224,6 +225,7 @@ suite('single-element binding effects', function() { el.divide = 3; assert.equal(el.$.boundChild.computedInline, 20, 'computedInline 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'); }); @@ -232,6 +234,7 @@ suite('single-element binding effects', function() { el.add = 40; el.divide = 3; 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() { From b40f639b63df9533b92029fa533f70db44997466 Mon Sep 17 00:00:00 2001 From: Michael Giuffrida Date: Wed, 3 Feb 2016 21:50:33 -0800 Subject: [PATCH 3/3] i suck at git --- src/standard/effectBuilder.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/standard/effectBuilder.html b/src/standard/effectBuilder.html index 27730ec4..a99d4d26 100644 --- a/src/standard/effectBuilder.html +++ b/src/standard/effectBuilder.html @@ -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])` _parseMethod: function(expression) { // tries to match valid javascript property names - var m = expression.match(/([^\s]+?)\((.*)\)/); + var m = expression.match(/([^\s]+?)\(([\s\S]*)\)/); if (m) { var sig = { method: m[1], static: true }; if (m[2].trim()) {