From 0a4601bc1a54d2930cbe36e989367579f7055e45 Mon Sep 17 00:00:00 2001 From: Justineo Date: Thu, 29 Dec 2022 18:13:51 +0800 Subject: [PATCH] feat: delay disposal to disconnection if possible --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- README.zh-Hans.md | 4 ++-- package.json | 2 +- src/ECharts.ts | 19 ++++++++++++++---- src/wc.ts | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 src/wc.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index a3321c5..7f11b7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.4.0 + +* Delay the disposal of the ECharts instance to the moment the element is disconnected from the DOM if possible (#433). + ## 6.3.3 * Make autoresize work for grid layout by default (#675). diff --git a/README.md b/README.md index d895e82..0e33297 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ Drop ` - + ``` @@ -247,7 +247,7 @@ app.component('v-chart', VueECharts) ```html - + ``` diff --git a/README.zh-Hans.md b/README.zh-Hans.md index a4b7ed5..e175b7e 100644 --- a/README.zh-Hans.md +++ b/README.zh-Hans.md @@ -225,7 +225,7 @@ import "echarts"; ```html - + ``` @@ -245,7 +245,7 @@ app.component('v-chart', VueECharts) ```html - + ``` diff --git a/package.json b/package.json index 349d5be..bbadd7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-echarts", - "version": "6.3.3", + "version": "6.4.0", "description": "Vue.js component for Apache ECharts.", "author": "GU Yiling ", "scripts": { diff --git a/src/ECharts.ts b/src/ECharts.ts index 1d51be3..237d068 100644 --- a/src/ECharts.ts +++ b/src/ECharts.ts @@ -8,7 +8,7 @@ import { computed, inject, onMounted, - onUnmounted, + onBeforeUnmount, h, nextTick, watchEffect, @@ -38,9 +38,10 @@ import { loadingProps } from "./composables"; import { omitOn, unwrapInjected } from "./utils"; +import { register, TAG_NAME, type EChartsElement } from "./wc"; import "./style.css"; -const TAG_NAME = "x-vue-echarts"; +const wcRegistered = register(); if (Vue2) { Vue2.config.ignoredElements.push(TAG_NAME); @@ -70,7 +71,7 @@ export default defineComponent({ emits: [] as unknown as Emits, inheritAttrs: false, setup(props, { attrs }) { - const root = shallowRef(); + const root = shallowRef(); const chart = shallowRef(); const manualOption = shallowRef