@@ -1440,7 +1440,7 @@ impl<'a> Context<'a> {
1440
1440
if !self . should_write_global ( "text_encoder" ) {
1441
1441
return Ok ( ( ) ) ;
1442
1442
}
1443
- self . expose_text_processor ( "TextEncoder" , "('utf-8')" , None )
1443
+ self . expose_text_processor ( "TextEncoder" , "encode" , " ('utf-8')", None )
1444
1444
}
1445
1445
1446
1446
fn expose_text_decoder ( & mut self ) -> Result < ( ) , Error > {
@@ -1456,6 +1456,7 @@ impl<'a> Context<'a> {
1456
1456
// `fatal` is needed to catch any weird encoding bugs when sending a string from Rust to JS
1457
1457
self . expose_text_processor (
1458
1458
"TextDecoder" ,
1459
+ "decode" ,
1459
1460
"('utf-8', { ignoreBOM: true, fatal: true })" ,
1460
1461
init,
1461
1462
) ?;
@@ -1466,6 +1467,7 @@ impl<'a> Context<'a> {
1466
1467
fn expose_text_processor (
1467
1468
& mut self ,
1468
1469
s : & str ,
1470
+ op : & str ,
1469
1471
args : & str ,
1470
1472
init : Option < & str > ,
1471
1473
) -> Result < ( ) , Error > {
@@ -1496,7 +1498,7 @@ impl<'a> Context<'a> {
1496
1498
| OutputMode :: Web
1497
1499
| OutputMode :: NoModules { .. }
1498
1500
| OutputMode :: Bundler { browser_only : true } => {
1499
- self . global ( & format ! ( "const cached{0} = (typeof {0} !== 'undefined' ? new {0}{1} : {{ decode : () => {{ throw Error('{0} not available') }} }} );" , s, args) )
1501
+ self . global ( & format ! ( "const cached{0} = (typeof {0} !== 'undefined' ? new {0}{1} : {{ {2} : () => {{ throw Error('{0} not available') }} }} );" , s, args, op ) )
1500
1502
}
1501
1503
} ;
1502
1504
0 commit comments