From e880baf11ddd49f7d961de16a7e28a85199c58e6 Mon Sep 17 00:00:00 2001 From: Pauan Date: Wed, 23 Oct 2019 00:26:28 +0200 Subject: [PATCH] Working around bug in Safari (#1829) --- crates/cli-support/src/js/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 4829ef65eeb..077480b3351 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -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(()) }