@@ -695,7 +695,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {
695
695
var pathVal = ( locals && locals . hasOwnProperty ( key0 ) ) ? locals : scope ,
696
696
promise ;
697
697
698
- if ( ! pathVal ) return pathVal ;
698
+ if ( pathVal === null || pathVal === undefined ) return pathVal ;
699
699
700
700
pathVal = pathVal [ key0 ] ;
701
701
if ( pathVal && pathVal . then ) {
@@ -706,7 +706,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {
706
706
}
707
707
pathVal = pathVal . $$v ;
708
708
}
709
- if ( ! key1 || ! pathVal ) return pathVal ;
709
+ if ( ! key1 || pathVal === null || pathVal === undefined ) return pathVal ;
710
710
711
711
pathVal = pathVal [ key1 ] ;
712
712
if ( pathVal && pathVal . then ) {
@@ -717,7 +717,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {
717
717
}
718
718
pathVal = pathVal . $$v ;
719
719
}
720
- if ( ! key2 || ! pathVal ) return pathVal ;
720
+ if ( ! key2 || pathVal === null || pathVal === undefined ) return pathVal ;
721
721
722
722
pathVal = pathVal [ key2 ] ;
723
723
if ( pathVal && pathVal . then ) {
@@ -728,7 +728,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {
728
728
}
729
729
pathVal = pathVal . $$v ;
730
730
}
731
- if ( ! key3 || ! pathVal ) return pathVal ;
731
+ if ( ! key3 || pathVal === null || pathVal === undefined ) return pathVal ;
732
732
733
733
pathVal = pathVal [ key3 ] ;
734
734
if ( pathVal && pathVal . then ) {
@@ -739,7 +739,7 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4) {
739
739
}
740
740
pathVal = pathVal . $$v ;
741
741
}
742
- if ( ! key4 || ! pathVal ) return pathVal ;
742
+ if ( ! key4 || pathVal === null || pathVal === undefined ) return pathVal ;
743
743
744
744
pathVal = pathVal [ key4 ] ;
745
745
if ( pathVal && pathVal . then ) {
@@ -767,18 +767,21 @@ function getterFn(path, csp) {
767
767
fn = ( pathKeysLength < 6 )
768
768
? cspSafeGetterFn ( pathKeys [ 0 ] , pathKeys [ 1 ] , pathKeys [ 2 ] , pathKeys [ 3 ] , pathKeys [ 4 ] )
769
769
: function ( scope , locals ) {
770
- var i = 0 , val ;
770
+ var i = 0 , val
771
771
do {
772
772
val = cspSafeGetterFn (
773
773
pathKeys [ i ++ ] , pathKeys [ i ++ ] , pathKeys [ i ++ ] , pathKeys [ i ++ ] , pathKeys [ i ++ ]
774
774
) ( scope , locals ) ;
775
+
775
776
locals = undefined ; // clear after first iteration
777
+ scope = val ;
776
778
} while ( i < pathKeysLength ) ;
777
- } ;
779
+ return val ;
780
+ }
778
781
} else {
779
782
var code = 'var l, fn, p;\n' ;
780
783
forEach ( pathKeys , function ( key , index ) {
781
- code += 'if(!s ) return s;\n' +
784
+ code += 'if(s === null || s === undefined ) return s;\n' +
782
785
'l=s;\n' +
783
786
's=' + ( index
784
787
// we simply dereference 's' on any .dot notation
0 commit comments