Skip to content

Commit

Permalink
fix(tauri) ensure css content is loaded inside a string (#884)
Browse files Browse the repository at this point in the history
Signed-off-by: Chip Reed <chip@chip.sh>
  • Loading branch information
chippers committed Jul 22, 2020
1 parent 91f1c88 commit e3e2e39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/load-asset-css.md
@@ -0,0 +1,5 @@
---
"tauri": patch
---

make sure css content injected is inside a string and not injected raw
12 changes: 6 additions & 6 deletions tauri/src/endpoints/asset.rs
Expand Up @@ -65,15 +65,15 @@ pub fn load(
if asset_type == "stylesheet" {
webview_ref.eval(&format!(
r#"
(function () {{
(function (content) {{
var css = document.createElement('style')
css.type = 'text/css'
if (css.styleSheet)
css.styleSheet.cssText = {css}
else
css.appendChild(document.createTextNode({css}))
if (css.styleSheet)
css.styleSheet.cssText = content
else
css.appendChild(document.createTextNode(content))
document.getElementsByTagName("head")[0].appendChild(css);
}})()
}})("{css}")
"#,
css = asset_str
));
Expand Down

0 comments on commit e3e2e39

Please sign in to comment.