@@ -873,7 +873,7 @@ ASTCompiler.prototype = {
873
873
break ;
874
874
case AST . LogicalExpression :
875
875
intoId = intoId || this . nextId ( ) ;
876
- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
876
+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
877
877
self . recurse ( ast . left , intoId ) ;
878
878
self . if ( ast . operator === '&&' ? intoId : self . not ( intoId ) , self . lazyRecurse ( ast . right , intoId ) ) ;
879
879
recursionFn ( intoId ) ;
@@ -884,7 +884,7 @@ ASTCompiler.prototype = {
884
884
break ;
885
885
case AST . ConditionalExpression :
886
886
intoId = intoId || this . nextId ( ) ;
887
- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
887
+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
888
888
self . recurse ( ast . test , intoId ) ;
889
889
self . if ( intoId , self . lazyRecurse ( ast . alternate , intoId ) , self . lazyRecurse ( ast . consequent , intoId ) ) ;
890
890
recursionFn ( intoId ) ;
@@ -900,9 +900,9 @@ ASTCompiler.prototype = {
900
900
nameId . computed = false ;
901
901
nameId . name = ast . name ;
902
902
}
903
- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
903
+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
904
904
ensureSafeMemberName ( ast . name ) ;
905
- self . if ( self . stage === 'inputs' || self . not ( self . getHasOwnProperty ( 'l' , ast . name ) ) ,
905
+ self . unless ( self . stage !== 'inputs' && self . getHasOwnProperty ( 'l' , ast . name ) ,
906
906
function ( ) {
907
907
self . if ( 's' , function ( ) {
908
908
if ( create && create !== 1 ) {
@@ -926,7 +926,7 @@ ASTCompiler.prototype = {
926
926
case AST . MemberExpression :
927
927
left = nameId && ( nameId . context = this . nextId ( ) ) || this . nextId ( ) ;
928
928
intoId = intoId || this . nextId ( ) ;
929
- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
929
+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
930
930
self . recurse ( ast . object , left , undefined , function ( ) {
931
931
self . if ( self . notNull ( left ) , function ( ) {
932
932
if ( ast . computed ) {
@@ -967,7 +967,7 @@ ASTCompiler.prototype = {
967
967
break ;
968
968
case AST . CallExpression :
969
969
intoId = intoId || this . nextId ( ) ;
970
- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
970
+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
971
971
if ( ast . filter ) {
972
972
right = self . filter ( ast . callee . name ) ;
973
973
args = [ ] ;
@@ -1107,6 +1107,8 @@ ASTCompiler.prototype = {
1107
1107
'if' : function ( test , alternate , consequent ) {
1108
1108
if ( test === true ) {
1109
1109
alternate ( ) ;
1110
+ } else if ( test === false ) {
1111
+ consequent ( ) ;
1110
1112
} else {
1111
1113
var body = this . current ( ) . body ;
1112
1114
body . push ( 'if(' , test , '){' ) ;
@@ -1119,6 +1121,9 @@ ASTCompiler.prototype = {
1119
1121
}
1120
1122
}
1121
1123
} ,
1124
+ unless : function ( test , alternate , consequent ) {
1125
+ return consequent ? this . if ( test , consequent , alternate ) : this . if ( this . not ( test ) , alternate ) ;
1126
+ } ,
1122
1127
1123
1128
not : function ( expression ) {
1124
1129
return '!(' + expression + ')' ;
0 commit comments