@@ -223,6 +223,15 @@ const normalizationMap = new WeakMap<
223
223
NormalizedPropsOptions
224
224
> ( )
225
225
226
+ function validatePropName ( key : string ) {
227
+ if ( key [ 0 ] !== '$' ) {
228
+ return true
229
+ } else if ( __DEV__ ) {
230
+ warn ( `Invalid prop name: "${ key } " is a reserved property.` )
231
+ }
232
+ return false
233
+ }
234
+
226
235
function normalizePropsOptions (
227
236
raw : ComponentPropsOptions | void
228
237
) : NormalizedPropsOptions {
@@ -240,10 +249,8 @@ function normalizePropsOptions(
240
249
warn ( `props must be strings when using array syntax.` , raw [ i ] )
241
250
}
242
251
const normalizedKey = camelize ( raw [ i ] )
243
- if ( normalizedKey [ 0 ] !== '$' ) {
252
+ if ( validatePropName ( normalizedKey ) ) {
244
253
options [ normalizedKey ] = EMPTY_OBJ
245
- } else if ( __DEV__ ) {
246
- warn ( `Invalid prop name: "${ normalizedKey } " is a reserved property.` )
247
254
}
248
255
}
249
256
} else {
@@ -252,7 +259,7 @@ function normalizePropsOptions(
252
259
}
253
260
for ( const key in raw ) {
254
261
const normalizedKey = camelize ( key )
255
- if ( normalizedKey [ 0 ] !== '$' ) {
262
+ if ( validatePropName ( normalizedKey ) ) {
256
263
const opt = raw [ key ]
257
264
const prop : NormalizedProp = ( options [ normalizedKey ] =
258
265
isArray ( opt ) || isFunction ( opt ) ? { type : opt } : opt )
@@ -267,8 +274,6 @@ function normalizePropsOptions(
267
274
needCastKeys . push ( normalizedKey )
268
275
}
269
276
}
270
- } else if ( __DEV__ ) {
271
- warn ( `Invalid prop name: "${ normalizedKey } " is a reserved property.` )
272
277
}
273
278
}
274
279
}
0 commit comments