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,13 +810,17 @@ function setAttribute(element: DOMElement, key: string, value: any, namespace?:
} else if (key.startsWith('on')) { } else if (key.startsWith('on')) {
addEventListener(element, key, value, key.endsWith('Capture')); addEventListener(element, key, value, key.endsWith('Capture'));
} else if ( } 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); element.setAttribute(key, value);
} else if (!FILTERED_ATTRIBUTES.has(key)) { } else if (!FILTERED_ATTRIBUTES.has(key)) {
if (namespace === SVG_NAMESPACE) {
element.setAttribute(key, value);
} else {
(element as any)[MAPPED_ATTRIBUTES[key] || key] = value; (element as any)[MAPPED_ATTRIBUTES[key] || key] = value;
} }
} }
}
function removeAttribute(element: DOMElement, key: string, value: any) { function removeAttribute(element: DOMElement, key: string, value: any) {
if (key === 'className') { if (key === 'className') {

View File

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