2019-11-24 21:00:46 +00:00
|
|
|
import { ElementWithTransition } from '../components/Transition'
|
2019-11-22 20:31:55 +00:00
|
|
|
|
2019-10-05 14:35:19 +00:00
|
|
|
// compiler should normalize class + :class bindings on the same element
|
2018-09-19 15:35:38 +00:00
|
|
|
// into a single binding ['staticClass', dynamic]
|
2019-11-22 20:31:55 +00:00
|
|
|
export function patchClass(
|
|
|
|
el: ElementWithTransition,
|
|
|
|
value: string,
|
|
|
|
isSVG: boolean
|
|
|
|
) {
|
|
|
|
// if this is an element during a transition, take the temporary transition
|
|
|
|
// classes into account.
|
|
|
|
if (el._vtc) {
|
|
|
|
value = [value, ...el._vtc].join(' ')
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|