mirror of
https://github.com/ecomfe/vue-echarts.git
synced 2025-10-30 00:18:36 +08:00
test: increase coverage and add codecov integration
This commit is contained in:
41
src/wc.ts
41
src/wc.ts
@ -1,3 +1,5 @@
|
||||
import { isBrowser } from "./utils";
|
||||
|
||||
let registered: boolean | null = null;
|
||||
|
||||
export const TAG_NAME = "x-vue-echarts";
|
||||
@ -11,30 +13,33 @@ export function register(): boolean {
|
||||
return registered;
|
||||
}
|
||||
|
||||
if (
|
||||
typeof HTMLElement === "undefined" ||
|
||||
typeof customElements === "undefined"
|
||||
) {
|
||||
return (registered = false);
|
||||
const registry = globalThis.customElements;
|
||||
|
||||
if (!isBrowser() || !registry?.get) {
|
||||
registered = false;
|
||||
return registered;
|
||||
}
|
||||
|
||||
try {
|
||||
class ECElement extends HTMLElement implements EChartsElement {
|
||||
__dispose: (() => void) | null = null;
|
||||
if (!registry.get(TAG_NAME)) {
|
||||
try {
|
||||
class ECElement extends HTMLElement implements EChartsElement {
|
||||
__dispose: (() => void) | null = null;
|
||||
|
||||
disconnectedCallback() {
|
||||
if (this.__dispose) {
|
||||
this.__dispose();
|
||||
this.__dispose = null;
|
||||
disconnectedCallback(): void {
|
||||
if (this.__dispose) {
|
||||
this.__dispose();
|
||||
this.__dispose = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registry.define(TAG_NAME, ECElement);
|
||||
} catch {
|
||||
registered = false;
|
||||
return registered;
|
||||
}
|
||||
if (customElements.get(TAG_NAME) == null) {
|
||||
customElements.define(TAG_NAME, ECElement);
|
||||
}
|
||||
} catch {
|
||||
return (registered = false);
|
||||
}
|
||||
|
||||
return (registered = true);
|
||||
registered = true;
|
||||
return registered;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user