Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit bbeeeb8

Browse files
committed
refactor($parse): merge ternary and ternaryFn methods
splitting the code into two chunks doesn't buy us anything and only makes the code harder to follow
1 parent 79d0d21 commit bbeeeb8

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/ng/parse.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -502,14 +502,6 @@ Parser.prototype = {
502502
});
503503
},
504504

505-
ternaryFn: function(left, middle, right){
506-
return extend(function $parseTernaryFn(self, locals){
507-
return left(self, locals) ? middle(self, locals) : right(self, locals);
508-
}, {
509-
constant: left.constant && middle.constant && right.constant
510-
});
511-
},
512-
513505
binaryFn: function(left, fn, right, isBranching) {
514506
return extend(function $parseBinaryFn(self, locals) {
515507
return fn(self, locals, left, right);
@@ -615,13 +607,20 @@ Parser.prototype = {
615607
if ((token = this.expect('?'))) {
616608
middle = this.assignment();
617609
if ((token = this.expect(':'))) {
618-
return this.ternaryFn(left, middle, this.assignment());
610+
var right = this.assignment();
611+
612+
return extend(function $parseTernary(self, locals){
613+
return left(self, locals) ? middle(self, locals) : right(self, locals);
614+
}, {
615+
constant: left.constant && middle.constant && right.constant
616+
});
617+
619618
} else {
620619
this.throwError('expected :', token);
621620
}
622-
} else {
623-
return left;
624621
}
622+
623+
return left;
625624
},
626625

627626
logicalOR: function() {

0 commit comments

Comments
 (0)