File tree Expand file tree Collapse file tree 2 files changed +102
-0
lines changed
Expand file tree Collapse file tree 2 files changed +102
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,57 @@ import { Window } from 'happy-dom'
1010
1111const window = new Window ( { url : 'http://localhost' } )
1212
13+ // Bun does not fully support Node.js vm module, so happy-dom's
14+ // VMGlobalPropertyScript never runs. We must manually assign native
15+ // error constructors that happy-dom's internals (e.g. SelectorParser)
16+ // expect to find on the Window object.
17+ const nativeGlobals : Record < string , unknown > = {
18+ Error,
19+ EvalError,
20+ RangeError,
21+ ReferenceError,
22+ SyntaxError,
23+ TypeError,
24+ URIError,
25+ Array,
26+ Object,
27+ Function,
28+ RegExp,
29+ Number,
30+ String,
31+ Boolean,
32+ Symbol,
33+ Map,
34+ Set,
35+ WeakMap,
36+ WeakSet,
37+ Promise,
38+ ArrayBuffer,
39+ DataView,
40+ Float32Array,
41+ Float64Array,
42+ Int8Array,
43+ Int16Array,
44+ Int32Array,
45+ Uint8Array,
46+ Uint16Array,
47+ Uint32Array,
48+ Uint8ClampedArray,
49+ JSON ,
50+ Math,
51+ Reflect,
52+ Intl,
53+ Date,
54+ AbortController,
55+ AbortSignal,
56+ }
57+
58+ for ( const [ key , value ] of Object . entries ( nativeGlobals ) ) {
59+ if ( ( window as any ) [ key ] === undefined ) {
60+ ; ( window as any ) [ key ] = value
61+ }
62+ }
63+
1364// Assign essential DOM globals to globalThis
1465const domGlobals = [
1566 'document' ,
Original file line number Diff line number Diff line change @@ -12,6 +12,57 @@ import { Window } from 'happy-dom'
1212
1313const window = new Window ( { url : 'http://localhost' } )
1414
15+ // Bun does not fully support Node.js vm module, so happy-dom's
16+ // VMGlobalPropertyScript never runs. We must manually assign native
17+ // error constructors that happy-dom's internals (e.g. SelectorParser)
18+ // expect to find on the Window object.
19+ const nativeGlobals : Record < string , unknown > = {
20+ Error,
21+ EvalError,
22+ RangeError,
23+ ReferenceError,
24+ SyntaxError,
25+ TypeError,
26+ URIError,
27+ Array,
28+ Object,
29+ Function,
30+ RegExp,
31+ Number,
32+ String,
33+ Boolean,
34+ Symbol,
35+ Map,
36+ Set,
37+ WeakMap,
38+ WeakSet,
39+ Promise,
40+ ArrayBuffer,
41+ DataView,
42+ Float32Array,
43+ Float64Array,
44+ Int8Array,
45+ Int16Array,
46+ Int32Array,
47+ Uint8Array,
48+ Uint16Array,
49+ Uint32Array,
50+ Uint8ClampedArray,
51+ JSON ,
52+ Math,
53+ Reflect,
54+ Intl,
55+ Date,
56+ AbortController,
57+ AbortSignal,
58+ }
59+
60+ for ( const [ key , value ] of Object . entries ( nativeGlobals ) ) {
61+ if ( ( window as any ) [ key ] === undefined ) {
62+ ; ( window as any ) [ key ] = value
63+ }
64+ }
65+
1566const domGlobals = [
1667 'document' ,
1768 'window' ,
You can’t perform that action at this time.
0 commit comments