diff --git a/src/visual/aria.ts b/src/visual/aria.ts index 3f420588bc..fae8999877 100644 --- a/src/visual/aria.ts +++ b/src/visual/aria.ts @@ -139,6 +139,12 @@ export default function ariaVisual(ecModel: GlobalModel, api: ExtensionAPI) { } function setLabel() { + const dom = api.getZr().dom; + // TODO: support for SSR + if (!dom) { + return; + } + const labelLocale = ecModel.getLocaleModel().get('aria'); const labelModel = ariaModel.getModel('label'); labelModel.option = zrUtil.defaults(labelModel.option, labelLocale); @@ -147,7 +153,6 @@ export default function ariaVisual(ecModel: GlobalModel, api: ExtensionAPI) { return; } - const dom = api.getZr().dom; if (labelModel.get('description')) { dom.setAttribute('aria-label', labelModel.get('description')); return; diff --git a/test/node/ssr.js b/test/node/ssr.js index 5675f7691a..b89098585a 100644 --- a/test/node/ssr.js +++ b/test/node/ssr.js @@ -25,6 +25,10 @@ const chart = echarts.init(null, null, { }); chart.setOption({ + aria: { + // Not supported in SSR, but should not throw error + enabled: true, + }, series: [ { name: 'Nightingale Chart',