Merge pull request #2286 from nazar-pc/fix-for-2264

Support for negative numbers in computed bindings
This commit is contained in:
Daniel Freedman
2015-08-18 17:20:31 -07:00
3 changed files with 18 additions and 2 deletions

View File

@@ -211,6 +211,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
};
// detect literal value (must be String or Number)
var fc = arg[0];
if (fc === '-') {
fc = arg[1];
}
if (fc >= '0' && fc <= '9') {
fc = '#';
}

View File

@@ -11,6 +11,8 @@
computed-inline2="{{computeInline(value, add,divide)}}"
computedattribute$="{{computeInline(value, add,divide)}}"
neg-computed-inline="{{!computeInline(value,add,divide)}}"
computed-negative-number="{{computeNegativeNumber(-1)}}"
computed-negative-literal="{{computeNegativeNumber(-A)}}"
style$="{{boundStyle}}"
data-id$="{{dataSetId}}"
custom-event-value="{{customEventValue::custom}}"
@@ -232,6 +234,9 @@
},
computeFromNoArgs: function() {
return 'no args!';
},
computeNegativeNumber: function (num) {
return num;
}
});
</script>

View File

@@ -262,6 +262,14 @@ suite('single-element binding effects', function() {
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);
});
test('computed property with negative literal', function() {
assert.equal(el.$.boundChild.computedNegativeLiteral, undefined);
});
});
</script>
@@ -684,14 +692,14 @@ suite('warnings', function() {
<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>