Skip to content

Commit 89da9e4

Browse files
committed
fix(svg): compatible with the original icon behavior. when no primary or secondary color is passed, remove the fill attribute inside the icon
1 parent 01103de commit 89da9e4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/vue-common/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ export function svg({ name = 'Icon', component, filledComponent = null, deprecat
403403
context,
404404
extend
405405
})
406+
},
407+
mounted() {
408+
// 如果属性没有主副色,则遍历svg的所有内部元素,移除 fill 属性。
409+
// 注意:移除后不能还原,所以: 如果用户使用时不传入主副色,后来修改主副色有值,也无法再把fill还原回来的。
410+
if (this.firstColor === '' && this.secondColor === '') {
411+
this.$el?.querySelectorAll('*').forEach((path) => path.removeAttribute('fill'))
412+
}
406413
}
407414
})
408415
)

0 commit comments

Comments
 (0)