File tree 1 file changed +16
-8
lines changed
1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,18 @@ export default function setupNamespace(
13
13
log ?: LogHandler
14
14
) : string {
15
15
const parts = name . split ( '.' ) ;
16
- // Check if the key is exist in the prototype of the object
17
- const isReserved = parts [ 0 ] in { } ;
16
+ // Check if the key exists in the object's prototype.
17
+ const isReserved = parts [ 0 ] in Object . prototype ;
18
18
if ( log && isReserved ) {
19
19
log ( LOGLEVEL_WARN , logReservedNamespace ( parts [ 0 ] ) ) ;
20
20
}
21
21
parts [ 0 ] =
22
- ( typeof globals === 'function' ? globals ( parts [ 0 ] ) : isReserved ? null : globals [ parts [ 0 ] ] ) ||
23
- parts [ 0 ] ;
22
+ ( typeof globals === 'function'
23
+ ? globals ( parts [ 0 ] )
24
+ : isReserved
25
+ ? parts [ 0 ]
26
+ : globals [ parts [ 0 ] ] ) || parts [ 0 ] ;
27
+
24
28
parts . pop ( ) ;
25
29
26
30
let propertyPath = root ;
@@ -43,14 +47,18 @@ export function assignToDeepVariable(
43
47
log ?: LogHandler
44
48
) : string {
45
49
const parts = deepName . split ( '.' ) ;
46
- // Check if the key is exist in the prototype of the object
47
- const isReserved = parts [ 0 ] in { } ;
50
+ // Check if the key exists in the object's prototype.
51
+ const isReserved = parts [ 0 ] in Object . prototype ;
48
52
if ( log && isReserved ) {
49
53
log ( LOGLEVEL_WARN , logReservedNamespace ( parts [ 0 ] ) ) ;
50
54
}
51
55
parts [ 0 ] =
52
- ( typeof globals === 'function' ? globals ( parts [ 0 ] ) : isReserved ? null : globals [ parts [ 0 ] ] ) ||
53
- parts [ 0 ] ;
56
+ ( typeof globals === 'function'
57
+ ? globals ( parts [ 0 ] )
58
+ : isReserved
59
+ ? parts [ 0 ]
60
+ : globals [ parts [ 0 ] ] ) || parts [ 0 ] ;
61
+
54
62
const last = parts . pop ( ) ! ;
55
63
56
64
let propertyPath = root ;
You can’t perform that action at this time.
0 commit comments