mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #2286 from nazar-pc/fix-for-2264
Support for negative numbers in computed bindings
This commit is contained in:
@@ -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 = '#';
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user