@@ -326,7 +326,7 @@ var LibraryHTML5 = {
326326 // (that will let !canvas map to the canvas held in Module.canvas).
327327 $specialHTMLTargets__docs: '/** @type {Object} */' ,
328328#if ENVIRONMENT_MAY_BE_WORKER || ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL || PTHREADS
329- $specialHTMLTargets: "[0, typeof document != 'undefined' ? document : 0, typeof window != 'undefined' ? window : 0]" ,
329+ $specialHTMLTargets: "[0, globalThis. document ?? 0, globalThis. window ?? 0]" ,
330330#else
331331 $specialHTMLTargets : "[0, document, window]" ,
332332#endif
@@ -345,7 +345,7 @@ var LibraryHTML5 = {
345345 $findEventTarget : ( target ) = > {
346346 target = maybeCStringToJsString ( target ) ;
347347#if ENVIRONMENT_MAY_BE_WORKER || ENVIRONMENT_MAY_BE_NODE
348- var domElement = specialHTMLTargets [ target ] || ( typeof document != 'undefined' ? document . querySelector ( target ) : null ) ;
348+ var domElement = specialHTMLTargets [ target ] || globalThis . document ? .querySelector ( target ) ;
349349#else
350350 var domElement = specialHTMLTargets [ target ] || document . querySelector ( target ) ;
351351#endif
@@ -376,7 +376,7 @@ var LibraryHTML5 = {
376376 || specialHTMLTargets [ target ]
377377 // If that is not found either, query via the regular DOM selector.
378378#if PTHREADS
379- || ( typeof document != 'undefined' && document . querySelector ( target ) ) ;
379+ || globalThis . document ? .querySelector ( target ) ;
380380#else
381381 || document . querySelector ( target ) ;
382382#endif
@@ -403,7 +403,7 @@ var LibraryHTML5 = {
403403 else if ( target === '#canvas' ) return Module [ 'canvas' ] ;
404404 else if ( typeof target == 'string' )
405405#if ENVIRONMENT_MAY_BE_WORKER || ENVIRONMENT_MAY_BE_NODE
406- return ( typeof document != 'undefined' ) ? document . getElementById ( target ) : null ;
406+ return globalThis . document ? .getElementById ( target ) ;
407407#else
408408 return document . getElementById ( target ) ;
409409#endif
@@ -415,10 +415,10 @@ var LibraryHTML5 = {
415415 $findCanvasEventTarget : ( target ) = > {
416416 if ( typeof target == 'number' ) target = UTF8ToString ( target ) ;
417417 if ( ! target || target === '#canvas' ) {
418- if ( typeof GL != 'undefined' && GL . offscreenCanvases [ 'canvas' ] ) return GL . offscreenCanvases [ 'canvas' ] ; // TODO: Remove this line, target '#canvas' should refer only to Module['canvas'], not to GL.offscreenCanvases['canvas'] - but need stricter tests to be able to remove this line.
418+ if ( globalThis . GL ? .offscreenCanvases [ 'canvas' ] ) return GL . offscreenCanvases [ 'canvas' ] ; // TODO: Remove this line, target '#canvas' should refer only to Module['canvas'], not to GL.offscreenCanvases['canvas'] - but need stricter tests to be able to remove this line.
419419 return Module [ 'canvas' ] ;
420420 }
421- if ( typeof GL != 'undefined' && GL . offscreenCanvases [ target ] ) return GL . offscreenCanvases [ target ] ;
421+ if ( globalThis . GL ? .offscreenCanvases [ target ] ) return GL . offscreenCanvases [ target ] ;
422422 return findEventTarget ( target ) ;
423423 } ,
424424#endif
@@ -2072,8 +2072,8 @@ var LibraryHTML5 = {
20722072 { { { makeSetValue ( 'eventStruct' , C_STRUCTS . EmscriptenBatteryEvent . charging , 'battery.charging' , 'i8' ) } } } ;
20732073 } ,
20742074
2075- $hasBatteryAPI : ( ) = > typeof navigator != 'undefined' && navigator . getBattery ,
20762075 $hasBatteryAPI__internal : true ,
2076+ $hasBatteryAPI : ( ) = > globalThis . navigator ?. getBattery ,
20772077
20782078 $registerBatteryEventCallback__noleakcheck : true ,
20792079 $registerBatteryEventCallback__deps : [ '$JSEvents' , '$fillBatteryEventData' , 'malloc' ] ,
@@ -2388,7 +2388,7 @@ var LibraryHTML5 = {
23882388 emscripten_get_device_pixel_ratio__proxy : 'sync ',
23892389 emscripten_get_device_pixel_ratio : ( ) = > {
23902390#if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL
2391- return ( typeof devicePixelRatio == 'number' && devicePixelRatio ) || 1.0 ;
2391+ return globalThis . devicePixelRatio ?? 1.0 ;
23922392#else // otherwise, on the web and in workers, things are simpler
23932393 return devicePixelRatio ;
23942394#endif
0 commit comments