fs2005
fs2005

Reputation: 591

Why is this the variable not set?

Why is nonce undefined while debugging both in Chrome and Edge?

enter image description here

enter image description here

Setup:

Libraries:

Upvotes: 0

Views: 97

Answers (1)

Smileek
Smileek

Reputation: 2782

You have __webpack_nonce__ set in the script tag, so it's not undefined, and it's a global variable available everywhere in your code.

However, you check the type of the options.attributes which you don't pass to insertStyleElement: your screenshot

Therefore, {}.nonce === undefined

Looks like the easiest way to fix it is to remove the additional if (typeof attributes.nonce === "undefined") check, or to make sure you pass it when calling insertStyleElement.

Upvotes: 0

Related Questions