@@ -234,7 +234,7 @@ const Utils = {
234
234
* @returns {string }
235
235
*/
236
236
printable : function ( str , preserveWs ) {
237
- if ( typeof window !== "undefined" && window . app && ! window . app . options . treatAsUtf8 ) {
237
+ if ( ENVIRONMENT_IS_WEB ( ) && window . app && ! window . app . options . treatAsUtf8 ) {
238
238
str = Utils . byteArrayToChars ( Utils . strToByteArray ( str ) ) ;
239
239
}
240
240
@@ -384,8 +384,12 @@ const Utils = {
384
384
let wordArray = CryptoJS . enc . Utf8 . parse ( str ) ,
385
385
byteArray = Utils . wordArrayToByteArray ( wordArray ) ;
386
386
387
- if ( typeof window !== "undefined" && str . length !== wordArray . sigBytes ) {
388
- window . app . options . attemptHighlight = false ;
387
+ if ( str . length !== wordArray . sigBytes ) {
388
+ if ( ENVIRONMENT_IS_WORKER ( ) ) {
389
+ self . setOption ( "attemptHighlight" , false ) ;
390
+ } else if ( ENVIRONMENT_IS_WEB ( ) ) {
391
+ window . app . options . attemptHighlight = false ;
392
+ }
389
393
}
390
394
return byteArray ;
391
395
} ,
@@ -448,8 +452,13 @@ const Utils = {
448
452
let wordArray = new CryptoJS . lib . WordArray . init ( words , byteArray . length ) ,
449
453
str = CryptoJS . enc . Utf8 . stringify ( wordArray ) ;
450
454
451
- if ( typeof window !== "undefined" && str . length !== wordArray . sigBytes )
452
- window . app . options . attemptHighlight = false ;
455
+ if ( str . length !== wordArray . sigBytes ) {
456
+ if ( ENVIRONMENT_IS_WORKER ( ) ) {
457
+ self . setOption ( "attemptHighlight" , false ) ;
458
+ } else if ( ENVIRONMENT_IS_WEB ( ) ) {
459
+ window . app . options . attemptHighlight = false ;
460
+ }
461
+ }
453
462
return str ;
454
463
} catch ( err ) {
455
464
// If it fails, treat it as ANSI
0 commit comments