File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
packages/core/useScriptTag Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ export interface UseScriptTagOptions extends ConfigurableDocument {
45
45
*
46
46
*/
47
47
attrs ?: Record < string , string >
48
+
49
+ /**
50
+ * Nonce value for CSP (Content Security Policy)
51
+ * @default undefined
52
+ */
53
+ nonce ?: string
48
54
}
49
55
50
56
/**
@@ -71,6 +77,7 @@ export function useScriptTag(
71
77
defer,
72
78
document = defaultDocument ,
73
79
attrs = { } ,
80
+ nonce = undefined ,
74
81
} = options
75
82
const scriptTag = shallowRef < HTMLScriptElement | null > ( null )
76
83
@@ -117,7 +124,9 @@ export function useScriptTag(
117
124
el . noModule = noModule
118
125
if ( referrerPolicy )
119
126
el . referrerPolicy = referrerPolicy
120
-
127
+ if ( nonce ) {
128
+ el . nonce = nonce
129
+ }
121
130
Object . entries ( attrs ) . forEach ( ( [ name , value ] ) => el ?. setAttribute ( name , value ) )
122
131
123
132
// Enables shouldAppend
You can’t perform that action at this time.
0 commit comments