@@ -362,6 +362,8 @@ Parser.prototype = {
362
362
primary = this . arrayDeclaration ( ) ;
363
363
} else if ( this . expect ( '{' ) ) {
364
364
primary = this . object ( ) ;
365
+ } else if ( this . peek ( ) . identifier && this . peek ( ) . text in CONSTANTS ) {
366
+ primary = CONSTANTS [ this . consume ( ) . text ] ;
365
367
} else if ( this . peek ( ) . identifier ) {
366
368
primary = this . identifier ( ) ;
367
369
} else if ( this . peek ( ) . constant ) {
@@ -464,7 +466,7 @@ Parser.prototype = {
464
466
id += this . consume ( ) . text + this . consume ( ) . text ;
465
467
}
466
468
467
- return CONSTANTS [ id ] || getterFn ( id , this . options , this . text ) ;
469
+ return getterFn ( id , this . options , this . text ) ;
468
470
} ,
469
471
470
472
constant : function ( ) {
@@ -654,17 +656,16 @@ Parser.prototype = {
654
656
} ,
655
657
656
658
fieldAccess : function ( object ) {
657
- var expression = this . text ;
658
- var field = this . consume ( ) . text ;
659
- var getter = getterFn ( field , this . options , expression ) ;
659
+ var getter = this . identifier ( ) ;
660
660
661
661
return extend ( function $parseFieldAccess ( scope , locals , self ) {
662
- return getter ( self || object ( scope , locals ) ) ;
662
+ var o = self || object ( scope , locals ) ;
663
+ return ( o == null ) ? undefined : getter ( o ) ;
663
664
} , {
664
665
assign : function ( scope , value , locals ) {
665
666
var o = object ( scope , locals ) ;
666
667
if ( ! o ) object . assign ( scope , o = { } ) ;
667
- return setter ( o , field , value , expression ) ;
668
+ return getter . assign ( o , value ) ;
668
669
}
669
670
} ) ;
670
671
} ,
0 commit comments