feat(transition): handle transition classes when patching classes

This commit is contained in:
Evan You
2019-11-22 15:31:55 -05:00
parent 7859e4bce3
commit be9b4b2527
2 changed files with 45 additions and 14 deletions

View File

@@ -1,7 +1,17 @@
import { ElementWithTransition } from '../components/CSSTransition'
// compiler should normalize class + :class bindings on the same element
// into a single binding ['staticClass', dynamic]
export function patchClass(el: Element, value: string, isSVG: boolean) {
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(' ')
}
// directly setting className should be faster than setAttribute in theory
if (isSVG) {
el.setAttribute('class', value)