fix: Multiple UI component improvements and code quality enhancements (#23446)

This commit is contained in:
lyzno1
2025-08-05 19:36:07 +08:00
committed by GitHub
parent 5eb061466f
commit 2cd3fe0dce
6 changed files with 249 additions and 88 deletions

View File

@@ -14,9 +14,26 @@ export type Attrs = {
export function normalizeAttrs(attrs: Attrs = {}): Attrs {
return Object.keys(attrs).reduce((acc: Attrs, key) => {
// Filter out editor metadata attributes before processing
if (key.startsWith('inkscape:')
|| key.startsWith('sodipodi:')
|| key.startsWith('xmlns:inkscape')
|| key.startsWith('xmlns:sodipodi')
|| key.startsWith('xmlns:svg')
|| key === 'data-name')
return acc
const val = attrs[key]
key = key.replace(/([-]\w)/g, (g: string) => g[1].toUpperCase())
key = key.replace(/([:]\w)/g, (g: string) => g[1].toUpperCase())
// Additional filter after camelCase conversion
if (key === 'xmlnsInkscape'
|| key === 'xmlnsSodipodi'
|| key === 'xmlnsSvg'
|| key === 'dataName')
return acc
switch (key) {
case 'class':
acc.className = val