From fc53f50c3ed4ea71699121dacf38482e6a311f97 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Mon, 17 Aug 2015 02:06:30 +0200 Subject: [PATCH] Support for negative numbers in computed bindings --- src/standard/effectBuilder.html | 1 + test/unit/bind-elements.html | 4 ++++ test/unit/bind.html | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/standard/effectBuilder.html b/src/standard/effectBuilder.html index 26f5060ddb..d8cb0e1487 100644 --- a/src/standard/effectBuilder.html +++ b/src/standard/effectBuilder.html @@ -221,6 +221,7 @@ a.literal = true; break; case '#': + case '-': a.value = Number(arg); a.literal = true; break; diff --git a/test/unit/bind-elements.html b/test/unit/bind-elements.html index 8c83dc7863..388320a6e2 100644 --- a/test/unit/bind-elements.html +++ b/test/unit/bind-elements.html @@ -11,6 +11,7 @@ computed-inline2="{{computeInline(value, add,divide)}}" computedattribute$="{{computeInline(value, add,divide)}}" neg-computed-inline="{{!computeInline(value,add,divide)}}" + computed-negative-number="{{computeNegativeNumber(-1)}}" style$="{{boundStyle}}" data-id$="{{dataSetId}}" custom-event-value="{{customEventValue::custom}}" @@ -232,6 +233,9 @@ }, computeFromNoArgs: function() { return 'no args!'; + }, + computeNegativeNumber: function (num) { + return num; } }); diff --git a/test/unit/bind.html b/test/unit/bind.html index f0d0cbb5d2..e37478f3bb 100644 --- a/test/unit/bind.html +++ b/test/unit/bind.html @@ -262,6 +262,10 @@ assert.equal(el.observerCounts.customEventObjectValueChanged, 1, 'custom bound path observer not called'); }); + test('computed property with negative number', function() { + assert.equal(el.$.boundChild.computedNegativeNumber, -1); + }); + }); @@ -684,14 +688,14 @@