Open jcheringer opened 7 months ago
Makes sense. I think we can achieve this using our context system:
nonce
prop on StyleProvider
.StyleProvider
to the context system, so a consumer can override the nonce
prop on all StyleProvider
instances wrapped within a ContextSystemProvider
.Would that solution work for your use case? Are any of you available to submit a PR?
What problem does this address?
Some components (Modal, Popover.Slot) from the
@wordpress/components
package use their own StyleProvider, which, behind the scenes, creates an instance of the CacheProvider from the@emotion/react
package.However, there's no way to set a
nonce
for the CacheProvider, and in an application with more restrictive CSP (Content Security Policy) rules, the styles of StyledComponents inside a Modal or a Popover are not loaded correctly.I'm part of the team currently working on Gravatar. We are facing this issue while trying to reutilize the GradientPicker for a new feature.
What is your proposed solution?
Expose a nonce property for the StyleProvider so an application using the WordPress components can define a nonce when necessary.