File tree 1 file changed +12
-13
lines changed
packages/runtime-dom/src/modules
1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -3,22 +3,21 @@ import { ElementWithTransition } from '../components/Transition'
3
3
// compiler should normalize class + :class bindings on the same element
4
4
// into a single binding ['staticClass', dynamic]
5
5
export function patchClass ( el : Element , value : string | null , isSVG : boolean ) {
6
- if ( value == null ) {
7
- value = ''
6
+ // directly setting className should be faster than setAttribute in theory
7
+ // if this is an element during a transition, take the temporary transition
8
+ // classes into account.
9
+ const transitionClasses = ( el as ElementWithTransition ) . _vtc
10
+ if ( transitionClasses ) {
11
+ value = ( value
12
+ ? [ value , ...transitionClasses ]
13
+ : [ ...transitionClasses ]
14
+ ) . join ( ' ' )
8
15
}
9
- if ( isSVG ) {
16
+ if ( value == null ) {
17
+ el . removeAttribute ( 'class' )
18
+ } else if ( isSVG ) {
10
19
el . setAttribute ( 'class' , value )
11
20
} else {
12
- // directly setting className should be faster than setAttribute in theory
13
- // if this is an element during a transition, take the temporary transition
14
- // classes into account.
15
- const transitionClasses = ( el as ElementWithTransition ) . _vtc
16
- if ( transitionClasses ) {
17
- value = ( value
18
- ? [ value , ...transitionClasses ]
19
- : [ ...transitionClasses ]
20
- ) . join ( ' ' )
21
- }
22
21
el . className = value
23
22
}
24
23
}
You can’t perform that action at this time.
0 commit comments