Skip to content

Commit

Permalink
Merge pull request #19892 from OverflowCat/master
Browse files Browse the repository at this point in the history
fix(aria): avoid throwing error in SSR mode (#19191)
  • Loading branch information
plainheart authored May 6, 2024
2 parents bdc5d4f + 872ac99 commit 832cc51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/visual/aria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions test/node/ssr.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 832cc51

Please sign in to comment.