Plotly uses inline CSS
See original GitHub issueWhich necessitates the unsafe-inline
Content Security Policy directive, or another workaround. Can we get rid of the inline styling somehow?
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='), or a nonce ('nonce-...') is required to enable inline execution.
l.addStyleRule @ plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7
plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7 Uncaught TypeError: Cannot read property 'insertRule' of null
at Object.l.addStyleRule (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at Object.1.../src/lib (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at i (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7
at Object.724.../build/plotcss (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at i (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7
at Object.12.../src/core (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at i (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7
at Object.20../aggregate (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at i (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at t (plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7)
at plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7
at plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7
at plotly__SHA256:3b219dbb9a6101432f4c65d4d4f35a0c5bff2ed2b9d43a007d46faa937b2ac81.mjs:7
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:22 (12 by maintainers)
Top Results From Across the Web
Inline css being applied but not css file - Dash Python
I am trying to change the color of the foreground of the dropdown (the inside area). If I use the inline styling 'backgroundColor':...
Read more >Adding CSS & JS and Overriding the Page-Load Template
Learn how to add custom CSS and JS to your app as well as how to customize the HTML title, meta tags, and...
Read more >Possible to Update/Overwrite html tag styles with CSS inline?
I want to change the styles for the <body> tag (like changing the margins so my content doesn't begin to the left of...
Read more >Multiple fonts in graph title - plotly.js - Plotly Community Forum
... Title of the chart. is it possible if i could use HTML in Title area? ... You can use distinct span blocks...
Read more >Dash HTML Components | Dash for Python Documentation
Dash is a web app framework that provides pure Python abstraction around HTML, CSS, and JavaScript. Instead of writing HTML or using an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As discussed in https://github.com/plotly/dash-core-components/issues/752 - it’s apparently not the case that all inline styles are disallowed with strict CSP; just those set by providing the entire style attribute as a string. I don’t know what D3 does, but if it accesses the style as an object as React apparently does, we may not need to convert everything to presentation attributes after all. We’d still need to get rid of
Lib.addStyleRule
and require the CSS to be loaded separately.This could potentially be a build variant so that you’d only need the separate CSS with the CSP build, other users could continue using the single JS bundle.
One possibility here, from a conversation with @alexcjohnson, is that maybe it’s just our
addStyleRule
function that’s problematic here, and that it could “just” be replaced by some judicious usage ofdocument.getElementById("some_id").style.setProperty("background-color", "green")
(if, as @anders-kiaer has suggested, such usage is CSP-compliant!)… If someone from the community wants to try that to see if it clears up these errors, we would surely help you get that PR merged in.