From 7a26ce56f2df781935b81f127b6377a45ddb39bf Mon Sep 17 00:00:00 2001 From: plainheart Date: Wed, 3 Jan 2024 00:57:29 +0800 Subject: [PATCH] fix(ssr): remove redundant SVG attributes with `undefined` value. --- src/core/echarts.ts | 8 ++++++-- src/util/innerStore.ts | 2 +- test/svg-ssr.html | 38 +++++++++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/core/echarts.ts b/src/core/echarts.ts index aaf538c72e..69978fd34b 100644 --- a/src/core/echarts.ts +++ b/src/core/echarts.ts @@ -429,10 +429,14 @@ class ECharts extends Eventful { zrender.registerSSRDataGetter(el => { const ecData = getECData(el); + const dataIndex = ecData.dataIndex; + if (dataIndex == null) { + return; + } const hashMap = createHashMap(); hashMap.set('series_index', ecData.seriesIndex); - hashMap.set('data_index', ecData.dataIndex); - hashMap.set('ssr_type', ecData.ssrType); + hashMap.set('data_index', dataIndex); + ecData.ssrType && hashMap.set('ssr_type', ecData.ssrType); return hashMap; }); diff --git a/src/util/innerStore.ts b/src/util/innerStore.ts index a1ecb2a78c..cf9ede71a6 100644 --- a/src/util/innerStore.ts +++ b/src/util/innerStore.ts @@ -75,7 +75,7 @@ export const setCommonECData = (seriesIndex: number, dataType: SeriesDataType, d childECData.seriesIndex = seriesIndex; childECData.dataIndex = dataIdx; childECData.dataType = dataType; - childECData.ssrType === 'chart'; + childECData.ssrType = 'chart'; }); } } diff --git a/test/svg-ssr.html b/test/svg-ssr.html index af9a4dab77..c08e02fa7d 100644 --- a/test/svg-ssr.html +++ b/test/svg-ssr.html @@ -41,7 +41,6 @@ - +