Skip to content

Commit fa2c00a

Browse files
1-dilikelei董梁玮
andauthored
feat(useStyleTag): support passing nonce (#4749)
Co-authored-by: 董梁玮 <14070624+dong-liangwei123@user.noreply.gitee.com>
1 parent dd98a7a commit fa2c00a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/core/useStyleTag/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export interface UseStyleTagOptions extends ConfigurableDocument {
3030
* @default auto-incremented
3131
*/
3232
id?: string
33+
34+
/**
35+
* Nonce value for CSP (Content Security Policy)
36+
*
37+
* @default undefined
38+
*/
39+
nonce?: string
3340
}
3441

3542
export interface UseStyleTagReturn {
@@ -75,6 +82,8 @@ export function useStyleTag(
7582

7683
if (!el.isConnected) {
7784
el.id = id
85+
if (options.nonce)
86+
el.nonce = options.nonce
7887
if (options.media)
7988
el.media = options.media
8089
document.head.appendChild(el)

0 commit comments

Comments
 (0)