fix(tauri) ensure css content is loaded inside a string (#884)

Signed-off-by: Chip Reed <chip@chip.sh>
This commit is contained in:
chip 2020-07-22 14:45:59 -07:00 committed by GitHub
parent 91f1c88009
commit e3e2e39208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": patch
---
make sure css content injected is inside a string and not injected raw

View File

@ -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
));