Skip to content

Commit

Permalink
Working around bug in Safari (#1829)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauan authored and alexcrichton committed Oct 22, 2019
1 parent c1b4f67 commit e880baf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/cli-support/src/js/mod.rs
Expand Up @@ -1071,9 +1071,15 @@ impl<'a> Context<'a> {
if !self.should_write_global("text_decoder") {
return Ok(());
}

// `ignoreBOM` is needed so that the BOM will be preserved when sending a string from Rust to JS
// `fatal` is needed to catch any weird encoding bugs when sending a string from Rust to JS
self.expose_text_processor("TextDecoder", "('utf-8', { ignoreBOM: true, fatal: true })")?;

// This is needed to workaround a bug in Safari
// See: https://github.com/rustwasm/wasm-bindgen/issues/1825
self.global("cachedTextDecoder.decode();");

Ok(())
}

Expand Down

0 comments on commit e880baf

Please sign in to comment.