Skip to content

Commit

Permalink
Set nonce before inserting style element
Browse files Browse the repository at this point in the history
  • Loading branch information
eligrey committed Oct 18, 2024
1 parent f451eec commit 22bfd73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/transcend-io/consent-manager-ui.git"
},
"homepage": "https://github.com/transcend-io/consent-manager-ui",
"version": "4.19.0",
"version": "4.19.1",
"license": "MIT",
"main": "build/ui",
"files": [
Expand Down
12 changes: 6 additions & 6 deletions src/consent-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ export const injectConsentManagerApp = async (
shadowRoot.appendChild(appContainer);

// Don't inherit global styles
const style = appContainer.appendChild(
createHTMLElement<HTMLStyleElement>('style'),
);

// Append UI container to doc to activate style.sheet
(document.documentElement || document).append(consentManager);
const style = createHTMLElement<HTMLStyleElement>('style');

if (CSP_NONCE) {
style.nonce = CSP_NONCE;
}

appContainer.appendChild(style);

// Append UI container to doc to activate style.sheet
(document.documentElement || document).append(consentManager);

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
style
.sheet! // 1st rule so subsequent properties are reset
Expand Down

0 comments on commit 22bfd73

Please sign in to comment.