types: fix class module transition class typing
This commit is contained in:
parent
800b0f0e7a
commit
52239d137c
@ -2,20 +2,17 @@ import { ElementWithTransition } from '../components/Transition'
|
|||||||
|
|
||||||
// compiler should normalize class + :class bindings on the same element
|
// compiler should normalize class + :class bindings on the same element
|
||||||
// into a single binding ['staticClass', dynamic]
|
// into a single binding ['staticClass', dynamic]
|
||||||
export function patchClass(
|
export function patchClass(el: Element, value: string, isSVG: boolean) {
|
||||||
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(' ')
|
|
||||||
}
|
|
||||||
// directly setting className should be faster than setAttribute in theory
|
// directly setting className should be faster than setAttribute in theory
|
||||||
if (isSVG) {
|
if (isSVG) {
|
||||||
el.setAttribute('class', value)
|
el.setAttribute('class', value)
|
||||||
} else {
|
} else {
|
||||||
|
// if this is an element during a transition, take the temporary transition
|
||||||
|
// classes into account.
|
||||||
|
const transtionClasses = (el as ElementWithTransition)._vtc
|
||||||
|
if (transtionClasses) {
|
||||||
|
value = [value, ...transtionClasses].join(' ')
|
||||||
|
}
|
||||||
el.className = value
|
el.className = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user