Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content Security Policy: Replace style attributes with JavaScript styles #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zepich
Copy link

@zepich zepich commented May 14, 2023

To use the Spectrum Color Picker on a website with a Content Security Policy header, the use of the attribute style is only allowed if the header contains the param unsafe-inline. With this param, the header is more or less useless for CSS protection. If you have a CSP header, you do not want the param unsafe-inline in it.

The solution for this problem is straightforward: Instead of setting the attribute directly, we must use the JavaScript API to set the style properties.

To solve this, I've replaced the code with style attributes with jQuery elements to set the style values with the method .css().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant