parent
5af718ba41
commit
7013e8f578
@ -3,22 +3,21 @@ 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(el: Element, value: string | null, isSVG: boolean) {
|
export function patchClass(el: Element, value: string | null, isSVG: boolean) {
|
||||||
if (value == null) {
|
// directly setting className should be faster than setAttribute in theory
|
||||||
value = ''
|
// if this is an element during a transition, take the temporary transition
|
||||||
|
// classes into account.
|
||||||
|
const transitionClasses = (el as ElementWithTransition)._vtc
|
||||||
|
if (transitionClasses) {
|
||||||
|
value = (value
|
||||||
|
? [value, ...transitionClasses]
|
||||||
|
: [...transitionClasses]
|
||||||
|
).join(' ')
|
||||||
}
|
}
|
||||||
if (isSVG) {
|
if (value == null) {
|
||||||
|
el.removeAttribute('class')
|
||||||
|
} else if (isSVG) {
|
||||||
el.setAttribute('class', value)
|
el.setAttribute('class', value)
|
||||||
} else {
|
} else {
|
||||||
// directly setting className should be faster than setAttribute in theory
|
|
||||||
// if this is an element during a transition, take the temporary transition
|
|
||||||
// classes into account.
|
|
||||||
const transitionClasses = (el as ElementWithTransition)._vtc
|
|
||||||
if (transitionClasses) {
|
|
||||||
value = (value
|
|
||||||
? [value, ...transitionClasses]
|
|
||||||
: [...transitionClasses]
|
|
||||||
).join(' ')
|
|
||||||
}
|
|
||||||
el.className = value
|
el.className = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user