@@ -873,7 +873,7 @@ ASTCompiler.prototype = {
873873 break ;
874874 case AST . LogicalExpression :
875875 intoId = intoId || this . nextId ( ) ;
876- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
876+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
877877 self . recurse ( ast . left , intoId ) ;
878878 self . if ( ast . operator === '&&' ? intoId : self . not ( intoId ) , self . lazyRecurse ( ast . right , intoId ) ) ;
879879 recursionFn ( intoId ) ;
@@ -884,7 +884,7 @@ ASTCompiler.prototype = {
884884 break ;
885885 case AST . ConditionalExpression :
886886 intoId = intoId || this . nextId ( ) ;
887- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
887+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
888888 self . recurse ( ast . test , intoId ) ;
889889 self . if ( intoId , self . lazyRecurse ( ast . alternate , intoId ) , self . lazyRecurse ( ast . consequent , intoId ) ) ;
890890 recursionFn ( intoId ) ;
@@ -900,9 +900,9 @@ ASTCompiler.prototype = {
900900 nameId . computed = false ;
901901 nameId . name = ast . name ;
902902 }
903- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
903+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
904904 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 ) ,
906906 function ( ) {
907907 self . if ( 's' , function ( ) {
908908 if ( create && create !== 1 ) {
@@ -926,7 +926,7 @@ ASTCompiler.prototype = {
926926 case AST . MemberExpression :
927927 left = nameId && ( nameId . context = this . nextId ( ) ) || this . nextId ( ) ;
928928 intoId = intoId || this . nextId ( ) ;
929- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
929+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
930930 self . recurse ( ast . object , left , undefined , function ( ) {
931931 self . if ( self . notNull ( left ) , function ( ) {
932932 if ( ast . computed ) {
@@ -967,7 +967,7 @@ ASTCompiler.prototype = {
967967 break ;
968968 case AST . CallExpression :
969969 intoId = intoId || this . nextId ( ) ;
970- this . if ( isDefined ( ast . watchId ) ? '! i' : true , function ( ) {
970+ this . unless ( isDefined ( ast . watchId ) ? 'i' : false , function ( ) {
971971 if ( ast . filter ) {
972972 right = self . filter ( ast . callee . name ) ;
973973 args = [ ] ;
@@ -1107,6 +1107,8 @@ ASTCompiler.prototype = {
11071107 'if' : function ( test , alternate , consequent ) {
11081108 if ( test === true ) {
11091109 alternate ( ) ;
1110+ } else if ( test === false ) {
1111+ consequent ( ) ;
11101112 } else {
11111113 var body = this . current ( ) . body ;
11121114 body . push ( 'if(' , test , '){' ) ;
@@ -1119,6 +1121,9 @@ ASTCompiler.prototype = {
11191121 }
11201122 }
11211123 } ,
1124+ unless : function ( test , alternate , consequent ) {
1125+ return consequent ? this . if ( test , consequent , alternate ) : this . if ( this . not ( test ) , alternate ) ;
1126+ } ,
11221127
11231128 not : function ( expression ) {
11241129 return '!(' + expression + ')' ;
0 commit comments