-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Inject style via constructable CSSStyleSheet
and remove CSP entry
#847
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
base: 8.0
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
don’t think it’s necessary to add that runtime guard. We already ship a version without CSS injection so why not just use that? Since users need to include the CSS file manually anyway, they’re likely already aware of the caveat. |
Users only need to switch to 'vue-echarts/csp' in environments with strict CSP requirements. This change allows us to avoid introducing a breaking change by renaming the entry point. |
However, since styles are only applied on the client side, there’s a potential risk of layout mismatch between the server-rendered and client-rendered content. |
So let’s revert the above change and just rename ‘vue-echarts/csp’ to ‘vue-charts/unstyled’ ? |
If we truly want to eliminate the extra import, we could proceed as follows:
|
CSSStyleSheet
and remove CSP entry
@@ -411,9 +411,11 @@ The slot props correspond to the first parameter of the callback function. | |||
|
|||
Static methods can be accessed from [`echarts` itself](https://echarts.apache.org/en/api.html#echarts). | |||
|
|||
## CSP: `style-src` or `style-src-elem` | |||
## Style |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still keep the previous title as only users requiring strict CSP need to know this.
Edited
This PR replaces the previous CSP-specific import (
vue-echarts/csp
) by injecting component styles at runtime using the nativeCSSStyleSheet
constructor (with a<style>
-tag fallback). As a result:vue-echarts/csp
entry.styles.css
file is still published for manual inclusion in strict-CSP or legacy-browser projects.Migration & Backward Compatibility
vue-echart/csp
, usevue-echarts
instead.vue-echarts/styles.css
as before.For the full discussion and rationale, see the original comment
Old description
This PR aims to make
vue-echarts/index.js
not break in server-side rendering environments. Nuxt users don't need to usevue-charts/csp
now.Do we still need to rename
vue-echarts/csp
? If so, what aboutvue-echarts/unstyled
orvue-echarts/no-css
?