소스 검색

types: fix class module transition class typing

Evan You 6 년 전
부모
커밋
52239d137c
1개의 변경된 파일7개의 추가작업 그리고 10개의 파일을 삭제
  1. 7 10
      packages/runtime-dom/src/modules/class.ts

+ 7 - 10
packages/runtime-dom/src/modules/class.ts

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