Teact: Filter SVG attributes (#6628)

This commit is contained in:
zubiden 2026-01-20 12:00:54 +01:00 committed by Alexander Zinchuk
parent 7e7ecbe897
commit 496bc6e295
2 changed files with 7 additions and 2 deletions

View File

@ -810,11 +810,15 @@ function setAttribute(element: DOMElement, key: string, value: any, namespace?:
} else if (key.startsWith('on')) {
addEventListener(element, key, value, key.endsWith('Capture'));
} else if (
namespace === SVG_NAMESPACE || key.startsWith('data-') || key.startsWith('aria-') || HTML_ATTRIBUTES.has(key)
key.startsWith('data-') || key.startsWith('aria-') || HTML_ATTRIBUTES.has(key)
) {
element.setAttribute(key, value);
} else if (!FILTERED_ATTRIBUTES.has(key)) {
(element as any)[MAPPED_ATTRIBUTES[key] || key] = value;
if (namespace === SVG_NAMESPACE) {
element.setAttribute(key, value);
} else {
(element as any)[MAPPED_ATTRIBUTES[key] || key] = value;
}
}
}

View File

@ -1,3 +1,4 @@
/* eslint-disable react-x/no-unnecessary-use-prefix */
import type { ReactElement } from 'react';
import { DEBUG, DEBUG_MORE } from '../../config';