Skip to content

Commit

Permalink
Merge pull request #1048 from ecomfe/fix/svg-ssr/skip-undefined-attri…
Browse files Browse the repository at this point in the history
…bute

fix(svg): skip to set SSR attributes with `undefined` values
  • Loading branch information
Ovilia authored Jan 3, 2024
2 parents c4fc3e0 + 03d4cec commit e7caf87
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/svg/graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ function setMetaData(attrs: SVGVNodeAttrs, el: Path | TSpan | ZRImage) {
const metaData = getElementSSRData(el);
if (metaData) {
metaData.each((val, key) => {
attrs[(META_DATA_PREFIX + key).toLowerCase()]
= val + '';
val != null && (attrs[(META_DATA_PREFIX + key).toLowerCase()] = val + '');
});
if (el.isSilent()) {
attrs[META_DATA_PREFIX + 'silent'] = 'true';
Expand Down
4 changes: 1 addition & 3 deletions src/zrender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,7 @@ export function registerPainter(name: string, Ctor: PainterBaseCtor) {
export type ElementSSRData = zrUtil.HashMap<unknown>;
export type ElementSSRDataGetter<T> = (el: Element) => zrUtil.HashMap<T>;

let ssrDataGetter = function (el: Element): ElementSSRData {
return null;
}
let ssrDataGetter: ElementSSRDataGetter<unknown>;

export function getElementSSRData(el: Element): ElementSSRData {
if (typeof ssrDataGetter === 'function') {
Expand Down

0 comments on commit e7caf87

Please sign in to comment.