Skip to content

Commit 90a7cdc

Browse files
committed
Fix negation operator
1 parent e5e1c42 commit 90a7cdc

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ For TODO between alpha and release, see https://github.com/knockout/tko/issues/1
33

44
## 🏹 Alpha-1 ( Work in progress on the `master` branch )
55

6+
* Fix negation operator (-) application - integers `-1` work, as well as variables `-x` and expressions `-(x + y)`
67
* Use tko.binding.foreach for the `foreach` binding (based on brianmhunt/knockout-fast-foreach)
78
* Add `each` as an alias of `foreach`
89

dist/ko.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,7 +3162,7 @@ var operators$1 = {
31623162
'%': function mod(a, b) { return a % b; },
31633163
// sub/add
31643164
'+': function add(a, b) { return a + b; },
3165-
'-': function sub(a, b) { return a - b; },
3165+
'-': function sub(a, b) { return (a || 0) - (b || 0); },
31663166
// relational
31673167
'<': function lt(a, b) { return a < b; },
31683168
'<=': function le(a, b) { return a <= b; },
@@ -4074,7 +4074,7 @@ Parser.prototype.expression = function (filterable) {
40744074
break;
40754075
}
40764076

4077-
// infix operators
4077+
// infix or postfix operators
40784078
op = this.operator(true);
40794079

40804080
if (op === operators['?']) {

dist/tko.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,7 +3162,7 @@ var operators$1 = {
31623162
'%': function mod(a, b) { return a % b; },
31633163
// sub/add
31643164
'+': function add(a, b) { return a + b; },
3165-
'-': function sub(a, b) { return a - b; },
3165+
'-': function sub(a, b) { return (a || 0) - (b || 0); },
31663166
// relational
31673167
'<': function lt(a, b) { return a < b; },
31683168
'<=': function le(a, b) { return a <= b; },
@@ -4074,7 +4074,7 @@ Parser.prototype.expression = function (filterable) {
40744074
break;
40754075
}
40764076

4077-
// infix operators
4077+
// infix or postfix operators
40784078
op = this.operator(true);
40794079

40804080
if (op === operators['?']) {

0 commit comments

Comments
 (0)