Skip to content

Commit e3e2e39

Browse files
authored
fix(tauri) ensure css content is loaded inside a string (#884)
Signed-off-by: Chip Reed <chip@chip.sh>
1 parent 91f1c88 commit e3e2e39

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.changes/load-asset-css.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
make sure css content injected is inside a string and not injected raw

tauri/src/endpoints/asset.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ pub fn load(
6565
if asset_type == "stylesheet" {
6666
webview_ref.eval(&format!(
6767
r#"
68-
(function () {{
68+
(function (content) {{
6969
var css = document.createElement('style')
7070
css.type = 'text/css'
71-
if (css.styleSheet)
72-
css.styleSheet.cssText = {css}
73-
else
74-
css.appendChild(document.createTextNode({css}))
71+
if (css.styleSheet)
72+
css.styleSheet.cssText = content
73+
else
74+
css.appendChild(document.createTextNode(content))
7575
document.getElementsByTagName("head")[0].appendChild(css);
76-
}})()
76+
}})("{css}")
7777
"#,
7878
css = asset_str
7979
));

0 commit comments

Comments
 (0)