File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 4
4
isString ,
5
5
isObject ,
6
6
EMPTY_ARR ,
7
- extend ,
8
- PatchFlags
7
+ extend
9
8
} from '@vue/shared'
10
9
import {
11
10
ComponentInternalInstance ,
@@ -146,9 +145,7 @@ export function createVNode(
146
145
if ( isReactive ( props ) || SetupProxySymbol in props ) {
147
146
props = extend ( { } , props )
148
147
}
149
- // class normalization only needed if the vnode isn't generated by
150
- // compiler-optimized code
151
- if ( props . class != null && ! ( patchFlag & PatchFlags . CLASS ) ) {
148
+ if ( props . class != null ) {
152
149
props . class = normalizeClass ( props . class )
153
150
}
154
151
let { style } = props
Original file line number Diff line number Diff line change @@ -13,3 +13,19 @@ it('should support on-the-fly template compilation', () => {
13
13
createApp ( ) . mount ( App , container )
14
14
expect ( container . innerHTML ) . toBe ( `0` )
15
15
} )
16
+
17
+ it ( 'should correctly normalize class with on-the-fly template compilation' , ( ) => {
18
+ const container = document . createElement ( 'div' )
19
+ const App = {
20
+ template : `<div :class="{ test: demoValue, test2: !demoValue }"></div>` ,
21
+ data ( ) {
22
+ return {
23
+ demoValue : true
24
+ }
25
+ }
26
+ }
27
+ createApp ( ) . mount ( App , container )
28
+ const classes = container . firstElementChild ! . classList
29
+ expect ( classes . contains ( 'test' ) ) . toBe ( true )
30
+ expect ( classes . contains ( 'test2' ) ) . toBe ( false )
31
+ } )
You can’t perform that action at this time.
0 commit comments