@@ -28,7 +28,7 @@ export default class GlobalRegistrator {
28
28
throw new Error ( 'Failed to register. Happy DOM has already been globally registered.' ) ;
29
29
}
30
30
31
- const window = new GlobalWindow ( { ...options , console : global . console } ) ;
31
+ const window = new GlobalWindow ( { ...options , console : globalThis . console } ) ;
32
32
33
33
this . registered = { } ;
34
34
@@ -38,7 +38,7 @@ export default class GlobalRegistrator {
38
38
for ( const key of Object . keys ( propertyDescriptors ) ) {
39
39
if ( ! IGNORE_LIST . includes ( key ) ) {
40
40
const windowPropertyDescriptor = propertyDescriptors [ key ] ;
41
- const globalPropertyDescriptor = Object . getOwnPropertyDescriptor ( global , key ) ;
41
+ const globalPropertyDescriptor = Object . getOwnPropertyDescriptor ( globalThis , key ) ;
42
42
43
43
if (
44
44
globalPropertyDescriptor ?. value === undefined ||
@@ -48,11 +48,11 @@ export default class GlobalRegistrator {
48
48
49
49
// If the property is the window object, replace it with the global object
50
50
if ( windowPropertyDescriptor . value === window ) {
51
- window [ key ] = global ;
52
- windowPropertyDescriptor . value = global ;
51
+ window [ key ] = globalThis ;
52
+ windowPropertyDescriptor . value = globalThis ;
53
53
}
54
54
55
- Object . defineProperty ( global , key , {
55
+ Object . defineProperty ( globalThis , key , {
56
56
...windowPropertyDescriptor ,
57
57
configurable : true
58
58
} ) ;
@@ -69,18 +69,18 @@ export default class GlobalRegistrator {
69
69
70
70
// If the property is the window object, replace it with the global object
71
71
if ( propertyDescriptor . value === window ) {
72
- window [ key ] = global ;
73
- propertyDescriptor . value = global ;
72
+ window [ key ] = globalThis ;
73
+ propertyDescriptor . value = globalThis ;
74
74
}
75
75
76
- Object . defineProperty ( global , key , {
76
+ Object . defineProperty ( globalThis , key , {
77
77
...propertyDescriptor ,
78
78
configurable : true
79
79
} ) ;
80
80
}
81
81
82
82
// Set owner window on document to global
83
- global . document [ PropertySymbol . defaultView ] = global ;
83
+ globalThis . document [ PropertySymbol . defaultView ] = globalThis ;
84
84
}
85
85
86
86
/**
@@ -93,13 +93,13 @@ export default class GlobalRegistrator {
93
93
) ;
94
94
}
95
95
96
- const happyDOM = global . happyDOM ;
96
+ const happyDOM = globalThis . happyDOM ;
97
97
98
98
for ( const key of Object . keys ( this . registered ) ) {
99
99
if ( this . registered [ key ] !== null ) {
100
- Object . defineProperty ( global , key , this . registered [ key ] ) ;
100
+ Object . defineProperty ( globalThis , key , this . registered [ key ] ) ;
101
101
} else {
102
- delete global [ key ] ;
102
+ delete globalThis [ key ] ;
103
103
}
104
104
}
105
105
0 commit comments