From 6304a1b15a452df2cc0e6eb0c9b1198b37e8282f Mon Sep 17 00:00:00 2001 From: Justineo Date: Wed, 7 Dec 2022 19:44:29 +0800 Subject: [PATCH] fix: attributes should fall onto the root for Vue 2 (#670) --- src/ECharts.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ECharts.ts b/src/ECharts.ts index 8e88246..3321b52 100644 --- a/src/ECharts.ts +++ b/src/ECharts.ts @@ -281,7 +281,11 @@ export default defineComponent({ }; }, render() { - const attrs = { ...this.nonEventAttrs }; + // Vue 3 and Vue 2 have different vnode props format: + // See https://v3-migration.vuejs.org/breaking-changes/render-function-api.html#vnode-props-format + const attrs = ( + Vue2 ? { attrs: this.nonEventAttrs } : { ...this.nonEventAttrs } + ) as any; attrs.ref = "root"; attrs.class = attrs.class ? ["echarts"].concat(attrs.class) : "echarts"; return h(TAG_NAME, attrs);