Skip to content

Commit af16f46

Browse files
Add support for nonce attributes in runtime checking (#304)
* Add basic support for trusted types * Add support for nonce attributes in runtime checking
1 parent 30e1dfb commit af16f46

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/features/runtime-checks.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,20 @@ class DDGRuntimeChecks extends HTMLElement {
109109
}
110110

111111
// Reflect all props to the new element
112-
for (const param of Object.keys(this)) {
113-
if (shouldFilterKey(this.#tagName, 'property', param)) continue
114-
el[param] = this[param]
112+
const props = Object.keys(this)
113+
114+
// Nonce isn't enumerable so we need to add it manually
115+
props.push('nonce')
116+
117+
for (const prop of props) {
118+
if (shouldFilterKey(this.#tagName, 'property', prop)) continue
119+
el[prop] = this[prop]
120+
}
121+
122+
for (const sink of supportedSinks) {
123+
if (this.#sinks[sink]) {
124+
el[sink] = this.#sinks[sink]
125+
}
115126
}
116127

117128
for (const sink of supportedSinks) {

0 commit comments

Comments
 (0)