Remove "class-name" from svg icon (#33540)

Only use "class" attribute
This commit is contained in:
wxiaoguang 2025-02-10 04:39:54 +08:00 committed by GitHub
parent a52720b5b4
commit 06088ec672
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 30 deletions

View file

@ -201,7 +201,6 @@ export const SvgIcon = defineComponent({
props: {
name: {type: String as PropType<SvgName>, required: true},
size: {type: Number, default: 16},
className: {type: String, default: ''},
symbolId: {type: String},
},
render() {
@ -216,15 +215,7 @@ export const SvgIcon = defineComponent({
attrs[`^width`] = this.size;
attrs[`^height`] = this.size;
// make the <SvgIcon class="foo" class-name="bar"> classes work together
const classes: Array<string> = [];
for (const cls of svgOuter.classList) {
classes.push(cls);
}
// TODO: drop the `className/class-name` prop in the future, only use "class" prop
if (this.className) {
classes.push(...this.className.split(/\s+/).filter(Boolean));
}
const classes = Array.from(svgOuter.classList);
if (this.symbolId) {
classes.push('tw-hidden', 'svg-symbol-container');
svgInnerHtml = `<symbol id="${this.symbolId}" viewBox="${attrs['^viewBox']}">${svgInnerHtml}</symbol>`;