mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-10-27 19:13:59 +08:00
feat!: inject style via constructable CSSStyleSheet and remove CSP entry (#847)
* chore: not inject inline css on server * feat!: remove csp entry * keep csp title in readme * chore: switch to rolldown and tsdown * update * dedupe * update according to review * emphasize "both" in csp section * load css with unplugin-raw * change tsdown entry
This commit is contained in:
@ -41,7 +41,7 @@ import type {
|
||||
} from "./types";
|
||||
import type { EChartsElement } from "./wc";
|
||||
|
||||
import "./style.css";
|
||||
import "./style.ts";
|
||||
|
||||
const wcRegistered = register();
|
||||
|
||||
|
||||
@ -1,6 +1 @@
|
||||
x-vue-echarts {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
x-vue-echarts{display:block;width:100%;height:100%;min-width:0;}
|
||||
16
src/style.ts
Normal file
16
src/style.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import cssRules from "./style.css?raw";
|
||||
|
||||
if (typeof document !== "undefined") {
|
||||
if (
|
||||
Array.isArray(document.adoptedStyleSheets) &&
|
||||
"replaceSync" in CSSStyleSheet.prototype
|
||||
) {
|
||||
const sheet = new CSSStyleSheet();
|
||||
sheet.replaceSync(cssRules);
|
||||
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];
|
||||
} else {
|
||||
const styleEl = document.createElement("style");
|
||||
styleEl.textContent = cssRules;
|
||||
document.head.appendChild(styleEl);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user