@@ -82,7 +82,7 @@ function fetchDeleteCachedData(db, fetch, onsuccess, onerror) {
8282
8383 var fetch_attr = fetch + { { { C_STRUCTS . emscripten_fetch_t . __attributes } } } ;
8484 var path = HEAPU32 [ fetch_attr + { { { C_STRUCTS . emscripten_fetch_attr_t . destinationPath } } } >> 2 ] ;
85- if ( ! path ) path = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
85+ path || = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
8686 var pathStr = UTF8ToString ( path ) ;
8787
8888 try {
@@ -131,7 +131,7 @@ function fetchLoadCachedData(db, fetch, onsuccess, onerror) {
131131
132132 var fetch_attr = fetch + { { { C_STRUCTS . emscripten_fetch_t . __attributes } } } ;
133133 var path = HEAPU32 [ fetch_attr + { { { C_STRUCTS . emscripten_fetch_attr_t . destinationPath } } } >> 2 ] ;
134- if ( ! path ) path = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
134+ path || = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
135135 var pathStr = UTF8ToString ( path ) ;
136136
137137 try {
@@ -196,7 +196,7 @@ function fetchCacheData(/** @type {IDBDatabase} */ db, fetch, data, onsuccess, o
196196
197197 var fetch_attr = fetch + { { { C_STRUCTS . emscripten_fetch_t . __attributes } } } ;
198198 var destinationPath = HEAPU32 [ fetch_attr + { { { C_STRUCTS . emscripten_fetch_attr_t . destinationPath } } } >> 2 ] ;
199- if ( ! destinationPath ) destinationPath = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
199+ destinationPath || = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
200200 var destinationPathStr = UTF8ToString ( destinationPath ) ;
201201
202202 try {
@@ -246,7 +246,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
246246
247247 var fetch_attr = fetch + { { { C_STRUCTS . emscripten_fetch_t . __attributes } } } ;
248248 var requestMethod = UTF8ToString ( fetch_attr + { { { C_STRUCTS . emscripten_fetch_attr_t . requestMethod } } } ) ;
249- if ( ! requestMethod ) requestMethod = 'GET' ;
249+ requestMethod || = 'GET' ;
250250 var timeoutMsecs = { { { makeGetValue ( 'fetch_attr' , C_STRUCTS . emscripten_fetch_attr_t . timeoutMSecs , 'u32' ) } } } ;
251251 var userName = { { { makeGetValue ( 'fetch_attr' , C_STRUCTS . emscripten_fetch_attr_t . userName , '*' ) } } } ;
252252 var password = { { { makeGetValue ( 'fetch_attr' , C_STRUCTS . emscripten_fetch_attr_t . password , '*' ) } } } ;
@@ -352,12 +352,12 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
352352#if FETCH_DEBUG
353353 dbg ( `fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " succeeded with status ${ xhr . status } ` ) ;
354354#endif
355- if ( onsuccess ) onsuccess ( fetch , xhr , e ) ;
355+ onsuccess ?. ( fetch , xhr , e ) ;
356356 } else {
357357#if FETCH_DEBUG
358358 dbg ( `fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " failed with status ${ xhr . status } ` ) ;
359359#endif
360- if ( onerror ) onerror ( fetch , xhr , e ) ;
360+ onerror ?. ( fetch , xhr , e ) ;
361361 }
362362 } ;
363363 xhr . onerror = ( e ) => {
@@ -369,7 +369,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
369369 dbg ( `fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " finished with error, readyState ${ xhr . readyState } and status ${ xhr . status } ` ) ;
370370#endif
371371 saveResponseAndStatus ( ) ;
372- if ( onerror ) onerror ( fetch , xhr , e ) ;
372+ onerror ?. ( fetch , xhr , e ) ;
373373 } ;
374374 xhr . ontimeout = ( e ) => {
375375 // check if xhr was aborted by user and don't try to call back
@@ -379,7 +379,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
379379#if FETCH_DEBUG
380380 dbg ( `fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " timed out, readyState ${ xhr . readyState } and status ${ xhr . status } ` ) ;
381381#endif
382- if ( onerror ) onerror ( fetch , xhr , e ) ;
382+ onerror ?. ( fetch , xhr , e ) ;
383383 } ;
384384 xhr . onprogress = ( e ) => {
385385 // check if xhr was aborted by user and don't try to call back
@@ -408,7 +408,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
408408 if ( xhr . readyState >= 3 && xhr . status === 0 && e . loaded > 0 ) xhr . status = 200 ;
409409 HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . status } } } >> 1 ] = xhr . status ;
410410 if ( xhr . statusText ) stringToUTF8 ( xhr . statusText , fetch + { { { C_STRUCTS . emscripten_fetch_t . statusText } } } , 64 ) ;
411- if ( onprogress ) onprogress ( fetch , xhr , e ) ;
411+ onprogress ?. ( fetch , xhr , e ) ;
412412 if ( ptr ) {
413413 _free ( ptr ) ;
414414 }
@@ -423,7 +423,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
423423 if ( xhr . readyState >= 2 ) {
424424 HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . status } } } >> 1 ] = xhr . status ;
425425 }
426- if ( onreadystatechange ) onreadystatechange ( fetch , xhr , e ) ;
426+ onreadystatechange ?. ( fetch , xhr , e ) ;
427427 } ;
428428#if FETCH_DEBUG
429429 dbg ( `fetch: xhr.send(data=${ data } )` ) ;
@@ -434,7 +434,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
434434#if FETCH_DEBUG
435435 dbg ( `fetch: xhr failed with exception: ${ e } ` ) ;
436436#endif
437- if ( onerror ) onerror ( fetch , xhr , e ) ;
437+ onerror ?. ( fetch , xhr , e ) ;
438438 }
439439}
440440
@@ -466,14 +466,14 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
466466 { { { runtimeKeepalivePop ( ) } } }
467467 doCallback ( ( ) => {
468468 if ( onsuccess ) { { { makeDynCall ( 'vp' , 'onsuccess' ) } } } ( fetch ) ;
469- else if ( successcb ) successcb ( fetch ) ;
469+ else successcb ?. ( fetch ) ;
470470 } ) ;
471471 } ;
472472
473473 var reportProgress = ( fetch , xhr , e ) => {
474474 doCallback ( ( ) => {
475475 if ( onprogress ) { { { makeDynCall ( 'vp' , 'onprogress' ) } } } ( fetch ) ;
476- else if ( progresscb ) progresscb ( fetch ) ;
476+ else progresscb ?. ( fetch ) ;
477477 } ) ;
478478 } ;
479479
@@ -484,7 +484,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
484484 { { { runtimeKeepalivePop ( ) } } }
485485 doCallback ( ( ) => {
486486 if ( onerror ) { { { makeDynCall ( 'vp' , 'onerror' ) } } } ( fetch ) ;
487- else if ( errorcb ) errorcb ( fetch ) ;
487+ else errorcb ?. ( fetch ) ;
488488 } ) ;
489489 } ;
490490
@@ -494,7 +494,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
494494#endif
495495 doCallback ( ( ) => {
496496 if ( onreadystatechange ) { { { makeDynCall ( 'vp' , 'onreadystatechange' ) } } } ( fetch ) ;
497- else if ( readystatechangecb ) readystatechangecb ( fetch ) ;
497+ else readystatechangecb ?. ( fetch ) ;
498498 } ) ;
499499 } ;
500500
@@ -517,7 +517,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
517517 { { { runtimeKeepalivePop ( ) } } }
518518 doCallback ( ( ) => {
519519 if ( onsuccess ) { { { makeDynCall ( 'vp' , 'onsuccess' ) } } } ( fetch ) ;
520- else if ( successcb ) successcb ( fetch ) ;
520+ else successcb ?. ( fetch ) ;
521521 } ) ;
522522 } ;
523523 var storeError = ( fetch , xhr , e ) => {
@@ -527,7 +527,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
527527 { { { runtimeKeepalivePop ( ) } } }
528528 doCallback ( ( ) => {
529529 if ( onsuccess ) { { { makeDynCall ( 'vp' , 'onsuccess' ) } } } ( fetch ) ;
530- else if ( successcb ) successcb ( fetch ) ;
530+ else successcb ?. ( fetch ) ;
531531 } ) ;
532532 } ;
533533 fetchCacheData ( Fetch . dbInstance , fetch , xhr . response , storeSuccess , storeError ) ;
0 commit comments