Skip to content

Commit 4cc62a4

Browse files
Set nonce on <script> tag thru setAttribute() instead of .nonce property
HTMLScriptElement.nonce doesn’t work in all browsers – setAttribute() does.
1 parent a89e173 commit 4cc62a4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/gentle-melons-look.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-use-intercom': patch
3+
---
4+
5+
Repair nonces on <script> tags

packages/react-use-intercom/src/initialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const initialize = (appId: string, timeout: number = 0, cspNonce?: string) => {
3232
var s = d.createElement('script');
3333
s.type = 'text/javascript';
3434
s.async = true;
35-
if (cspNonce) s.nonce = cspNonce;
35+
if (cspNonce) s.setAttribute('nonce', cspNonce);
3636
s.src = 'https://widget.intercom.io/widget/' + appId;
3737
var x = d.getElementsByTagName('script')[0];
3838
x.parentNode.insertBefore(s, x);

0 commit comments

Comments
 (0)