-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: delay disposal to disconnection if possible
- Loading branch information
Showing
6 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,7 +227,7 @@ Drop `<script>` inside your HTML file and access the component via `window.VueEC | |
```html | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.3.3"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.4.0"></script> | ||
``` | ||
<!-- vue3Scripts:end --> | ||
|
||
|
@@ -247,7 +247,7 @@ app.component('v-chart', VueECharts) | |
```html | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.3.3"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.4.0"></script> | ||
``` | ||
<!-- vue2Scripts:end --> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,7 +225,7 @@ import "echarts"; | |
```html | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.3.3"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.4.0"></script> | ||
``` | ||
<!-- vue3Scripts:end --> | ||
|
||
|
@@ -245,7 +245,7 @@ app.component('v-chart', VueECharts) | |
```html | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.3.3"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/vue-echarts@6.4.0"></script> | ||
``` | ||
<!-- vue2Scripts:end --> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]>", | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
let registered: boolean | null = null; | ||
|
||
export const TAG_NAME = "x-vue-echarts"; | ||
|
||
export interface EChartsElement extends HTMLElement { | ||
__dispose: (() => void) | null; | ||
} | ||
|
||
export function register(): boolean { | ||
if (registered != null) { | ||
return registered; | ||
} | ||
|
||
if ( | ||
typeof HTMLElement === "undefined" || | ||
typeof customElements === "undefined" | ||
) { | ||
return (registered = false); | ||
} | ||
|
||
try { | ||
// Class definitions cannot be transpiled to ES5 | ||
// so we are doing a little trick here to ensure | ||
// we are using native classes. As we use this as | ||
// a progressive enhancement, it will be fine even | ||
// if the browser doesn't support native classes. | ||
const reg = new Function( | ||
"tag", | ||
`class EChartsElement extends HTMLElement { | ||
__dispose = null; | ||
disconnectedCallback() { | ||
if (this.__dispose) { | ||
this.__dispose(); | ||
this.__dispose = null; | ||
} | ||
} | ||
} | ||
if (customElements.get(tag) == null) { | ||
customElements.define(tag, EChartsElement); | ||
} | ||
` | ||
); | ||
reg(TAG_NAME); | ||
} catch (e) { | ||
return (registered = false); | ||
} | ||
|
||
return (registered = true); | ||
} |
0a4601b
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.
Successfully deployed to the following URLs:
vue-echarts – ./
vue-echarts-ecomfe.vercel.app
vue-echarts.dev
vue-echarts-git-main-ecomfe.vercel.app
vue-echarts.vercel.app