File tree 2 files changed +50
-2
lines changed
packages/runtime-core/src/compat
2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,35 @@ describe('compat: render function', () => {
60
60
} )
61
61
} )
62
62
63
+ test ( 'staticClass + class' , ( ) => {
64
+ expect (
65
+ h ( 'div' , {
66
+ class : { foo : true } ,
67
+ staticClass : 'bar'
68
+ } )
69
+ ) . toMatchObject ( {
70
+ props : {
71
+ class : 'bar foo'
72
+ }
73
+ } )
74
+ } )
75
+
76
+ test ( 'staticStyle + style' , ( ) => {
77
+ expect (
78
+ h ( 'div' , {
79
+ style : { color : 'red' } ,
80
+ staticStyle : { fontSize : '14px' }
81
+ } )
82
+ ) . toMatchObject ( {
83
+ props : {
84
+ style : {
85
+ color : 'red' ,
86
+ fontSize : '14px'
87
+ }
88
+ }
89
+ } )
90
+ } )
91
+
63
92
test ( 'on / nativeOn' , ( ) => {
64
93
const fn = ( ) => { }
65
94
expect (
Original file line number Diff line number Diff line change 2
2
extend ,
3
3
isArray ,
4
4
isObject ,
5
+ normalizeClass ,
6
+ normalizeStyle ,
5
7
ShapeFlags ,
6
8
toHandlerKey
7
9
} from '@vue/shared'
@@ -141,7 +143,13 @@ export function compatH(
141
143
}
142
144
}
143
145
144
- function convertLegacyProps ( legacyProps ?: LegacyVNodeProps ) : Data & VNodeProps {
146
+ function convertLegacyProps (
147
+ legacyProps ?: LegacyVNodeProps
148
+ ) : Data & VNodeProps | null {
149
+ if ( ! legacyProps ) {
150
+ return null
151
+ }
152
+
145
153
const converted : Data & VNodeProps = { }
146
154
147
155
for ( const key in legacyProps ) {
@@ -159,11 +167,22 @@ function convertLegacyProps(legacyProps?: LegacyVNodeProps): Data & VNodeProps {
159
167
: incoming
160
168
}
161
169
}
162
- } else {
170
+ } else if (
171
+ key !== 'refInFor' &&
172
+ key !== 'staticStyle' &&
173
+ key !== 'staticClass'
174
+ ) {
163
175
converted [ key ] = legacyProps [ key as keyof LegacyVNodeProps ]
164
176
}
165
177
}
166
178
179
+ if ( legacyProps . staticClass ) {
180
+ converted . class = normalizeClass ( [ legacyProps . staticClass , converted . class ] )
181
+ }
182
+ if ( legacyProps . staticStyle ) {
183
+ converted . style = normalizeStyle ( [ legacyProps . staticStyle , converted . style ] )
184
+ }
185
+
167
186
return converted
168
187
}
169
188
You can’t perform that action at this time.
0 commit comments