vue3-yuanma/packages/runtime-dom/src/modules/class.ts

12 lines
367 B
TypeScript
Raw Normal View History

2018-09-19 15:35:38 +00:00
// compiler should normlaize class + :class bindings on the same element
// into a single binding ['staticClass', dynamic]
2018-09-24 23:11:14 +00:00
export function patchClass(el: Element, value: string, isSVG: boolean) {
2018-09-19 15:35:38 +00:00
// directly setting className should be faster than setAttribute in theory
if (isSVG) {
2018-09-24 23:11:14 +00:00
el.setAttribute('class', value)
2018-09-19 15:35:38 +00:00
} else {
2018-09-24 23:11:14 +00:00
el.className = value
2018-09-19 15:35:38 +00:00
}
}