test: add test for runtime-dom/modules/class (#75)

This commit is contained in:
Haoqun Jiang
2019-12-10 03:52:20 +08:00
committed by Evan You
parent 2383b45e32
commit d1527fbee4
2 changed files with 197 additions and 1 deletions

View File

@@ -2,7 +2,10 @@ 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: Element, value: string, isSVG: boolean) {
export function patchClass(el: Element, value: string | null, isSVG: boolean) {
if (value == null) {
value = ''
}
// directly setting className should be faster than setAttribute in theory
if (isSVG) {
el.setAttribute('class', value)