Skip to content

Commit

Permalink
Support for negative numbers in computed bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Aug 17, 2015
1 parent a42ca09 commit fc53f50
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/standard/effectBuilder.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
a.literal = true;
break;
case '#':
case '-':
a.value = Number(arg);
a.literal = true;
break;
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 @@ -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}}"
Expand Down Expand Up @@ -232,6 +233,9 @@
},
computeFromNoArgs: function() {
return 'no args!';
},
computeNegativeNumber: function (num) {
return num;
}
});
</script>
Expand Down
8 changes: 6 additions & 2 deletions test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

});

</script>
Expand Down Expand Up @@ -684,14 +688,14 @@

<script>
suite('binding corner cases', function() {

// IE can create adjacent text nodes that split bindings; this test
// ensures the code that addresses this is functional
test('text binding after entity', function() {
var el = document.createElement('x-entity-and-binding');
assert.equal(el.$.binding.textContent, 'binding');
});

});
</script>

Expand Down

0 comments on commit fc53f50

Please sign in to comment.