Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fa2c00a

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

File tree

1 file changed

+9
-0
lines changed
Filter options

1 file changed

+9
-0
lines changed

‎packages/core/useStyleTag/index.ts

Copy file name to clipboardExpand all lines: packages/core/useStyleTag/index.ts
+9
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.