@@ -726,6 +726,7 @@ ASTCompiler.prototype = {
726
726
findConstantAndWatchExpressions ( ast . body [ i ] . expression , this . $filter ) ;
727
727
}
728
728
var toWatch = useInputs ( ast . body ) ? ast . body [ ast . body . length - 1 ] . expression . toWatch : [ ] ;
729
+ self . stage = 'inputs' ;
729
730
forEach ( toWatch , function ( watch , key ) {
730
731
var fnKey = 'fn' + key ;
731
732
self . state [ fnKey ] = { vars : [ ] , body : [ ] , own : { } } ;
@@ -736,6 +737,7 @@ ASTCompiler.prototype = {
736
737
self . state . inputs . push ( fnKey ) ;
737
738
watch . watchId = key ;
738
739
} ) ;
740
+ self . stage = 'main' ;
739
741
this . state . computing = 'fn' ;
740
742
for ( i = 0 ; i < ast . body . length ; ++ i ) {
741
743
if ( lastExpression ) this . current ( ) . body . push ( lastExpression , ';' ) ;
@@ -744,6 +746,7 @@ ASTCompiler.prototype = {
744
746
if ( lastExpression ) this . return ( lastExpression ) ;
745
747
var extra = '' ;
746
748
if ( ast . body . length === 1 && isAssignable ( ast . body [ 0 ] . expression ) ) {
749
+ self . stage = 'assign' ;
747
750
this . state . computing = 'assign' ;
748
751
var result = this . nextId ( ) ;
749
752
this . recurse ( { type : AST . AssignmentExpression , left : ast . body [ 0 ] . expression , right : { type : AST . NGValueParameter } , operator : '=' } , result ) ;
@@ -794,7 +797,7 @@ ASTCompiler.prototype = {
794
797
isLiteral ,
795
798
isConstant ) ;
796
799
/* jshint +W054 */
797
- this . state = undefined ;
800
+ this . state = this . stage = undefined ;
798
801
return fn ;
799
802
} ,
800
803
@@ -808,7 +811,7 @@ ASTCompiler.prototype = {
808
811
var self = this ;
809
812
forEach ( fns , function ( name ) {
810
813
result . push (
811
- 'var ' + name + ' = function(s,l ){' +
814
+ 'var ' + name + ' = function(s){' +
812
815
self . varsPrefix ( name ) +
813
816
self . body ( name ) +
814
817
'};' ) ;
@@ -893,13 +896,13 @@ ASTCompiler.prototype = {
893
896
case AST . Identifier :
894
897
intoId = intoId || this . nextId ( ) ;
895
898
if ( nameId ) {
896
- nameId . context = this . assign ( this . nextId ( ) , this . getHasOwnProperty ( 'l' , ast . name ) , '?l:s' ) ;
899
+ nameId . context = self . stage === 'inputs' ? 's' : this . assign ( this . nextId ( ) , this . getHasOwnProperty ( 'l' , ast . name ) , '?l:s' ) ;
897
900
nameId . computed = false ;
898
901
nameId . name = ast . name ;
899
902
}
900
903
this . if ( isDefined ( ast . watchId ) ? '!i' : true , function ( ) {
901
904
ensureSafeMemberName ( ast . name ) ;
902
- self . if ( self . not ( self . getHasOwnProperty ( 'l' , ast . name ) ) ,
905
+ self . if ( self . stage === 'inputs' || self . not ( self . getHasOwnProperty ( 'l' , ast . name ) ) ,
903
906
function ( ) {
904
907
self . if ( 's' , function ( ) {
905
908
if ( create && create !== 1 ) {
0 commit comments