@@ -323,7 +323,7 @@ var LibraryHTML5 = {
323323 // (that will let !canvas map to the canvas held in Module.canvas).
324324 $specialHTMLTargets__docs: '/** @type {Object} */' ,
325325#if ENVIRONMENT_MAY_BE_WORKER || ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL || PTHREADS
326- $specialHTMLTargets: "[0, typeof document != 'undefined' ? document : 0, typeof window != 'undefined' ? window : 0]" ,
326+ $specialHTMLTargets: "[0, globalThis. document ?? 0, globalThis. window ?? 0]" ,
327327#else
328328 $specialHTMLTargets : "[0, document, window]" ,
329329#endif
@@ -342,7 +342,7 @@ var LibraryHTML5 = {
342342 $findEventTarget : ( target ) = > {
343343 target = maybeCStringToJsString ( target ) ;
344344#if ENVIRONMENT_MAY_BE_WORKER || ENVIRONMENT_MAY_BE_NODE
345- var domElement = specialHTMLTargets [ target ] || ( typeof document != 'undefined' ? document . querySelector ( target ) : null ) ;
345+ var domElement = specialHTMLTargets [ target ] || globalThis . document ? .querySelector ( target ) ;
346346#else
347347 var domElement = specialHTMLTargets [ target ] || document . querySelector ( target ) ;
348348#endif
@@ -373,7 +373,7 @@ var LibraryHTML5 = {
373373 || specialHTMLTargets [ target ]
374374 // If that is not found either, query via the regular DOM selector.
375375#if PTHREADS
376- || ( typeof document != 'undefined' && document . querySelector ( target ) ) ;
376+ || globalThis . document ? .querySelector ( target ) ) ;
377377#else
378378 || document . querySelector ( target ) ;
379379#endif
@@ -400,7 +400,7 @@ var LibraryHTML5 = {
400400 else if ( target === '#canvas' ) return Module [ 'canvas' ] ;
401401 else if ( typeof target == 'string' )
402402#if ENVIRONMENT_MAY_BE_WORKER || ENVIRONMENT_MAY_BE_NODE
403- return ( typeof document != 'undefined' ) ? document . getElementById ( target ) : null ;
403+ return globalThis . document ? .getElementById ( target ) ;
404404#else
405405 return document . getElementById ( target ) ;
406406#endif
@@ -412,10 +412,10 @@ var LibraryHTML5 = {
412412 $findCanvasEventTarget : ( target ) = > {
413413 if ( typeof target == 'number' ) target = UTF8ToString ( target ) ;
414414 if ( ! target || target === '#canvas' ) {
415- 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.
415+ 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.
416416 return Module [ 'canvas' ] ;
417417 }
418- if ( typeof GL != 'undefined' && GL . offscreenCanvases [ target ] ) return GL . offscreenCanvases [ target ] ;
418+ if ( globalThis . GL ? .offscreenCanvases [ target ] ) return GL . offscreenCanvases [ target ] ;
419419 return findEventTarget ( target ) ;
420420 } ,
421421#endif
@@ -2069,8 +2069,8 @@ var LibraryHTML5 = {
20692069 { { { makeSetValue ( 'eventStruct' , C_STRUCTS . EmscriptenBatteryEvent . charging , 'battery.charging' , 'i8' ) } } } ;
20702070 } ,
20712071
2072- $hasBatteryAPI : ( ) = > typeof navigator != 'undefined' && navigator . getBattery ,
20732072 $hasBatteryAPI__internal : true ,
2073+ $hasBatteryAPI : ( ) = > globalThis . navigator ?. getBattery ,
20742074
20752075 $registerBatteryEventCallback__noleakcheck : true ,
20762076 $registerBatteryEventCallback__deps : [ '$JSEvents' , '$fillBatteryEventData' , 'malloc' ] ,
@@ -2385,7 +2385,7 @@ var LibraryHTML5 = {
23852385 emscripten_get_device_pixel_ratio__proxy : 'sync ',
23862386 emscripten_get_device_pixel_ratio : ( ) = > {
23872387#if ENVIRONMENT_MAY_BE_NODE || ENVIRONMENT_MAY_BE_SHELL
2388- return ( typeof devicePixelRatio == 'number' && devicePixelRatio ) || 1.0 ;
2388+ return globalThis . devicePixelRatio ?? 1.0 ;
23892389#else // otherwise, on the web and in workers, things are simpler
23902390 return devicePixelRatio ;
23912391#endif
0 commit comments