소스 검색

inject css with template string to allow for line breaks (#894)

* inject css with template string to allow for line breaks

alternative solution would to be implement a struct `JsStringLiteral`
with `fmt::Display` that escapes all forbidden codepoints from the spec
https://www.ecma-international.org/ecma-262/#sec-literals-string-literals

template string literal seems fine as all browsers that tauri supports have
had support for them for the past 3-4+ years

Signed-off-by: Chip Reed <chip@chip.sh>

* chore(changes) adjust change file

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
chip 5 년 전
부모
커밋
b96b1fb6b8
2개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      .changes/load-asset-css.md
  2. 1 1
      tauri/src/endpoints/asset.rs

+ 1 - 1
.changes/load-asset-css.md

@@ -2,4 +2,4 @@
 "tauri": patch
 ---
 
-make sure css content injected is inside a string and not injected raw
+Make sure CSS content loaded with the `loadAsset` API is inside a template string and not injected raw.

+ 1 - 1
tauri/src/endpoints/asset.rs

@@ -73,7 +73,7 @@ pub fn load(
                   else
                       css.appendChild(document.createTextNode(content))
                   document.getElementsByTagName("head")[0].appendChild(css);
-                }})("{css}")
+                }})(`{css}`)
               "#,
               css = asset_str
             ));