Skip to content

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

Open
zepich wants to merge 2 commits intoseballot:masterfrom
zepi:resolve-style-attributes
Open

Content Security Policy: Replace style attributes with JavaScript styles#41
zepich wants to merge 2 commits intoseballot:masterfrom
zepi:resolve-style-attributes

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