fix: Multiple UI component improvements and code quality enhancements (#23446)
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user