@@ -223,6 +223,15 @@ const normalizationMap = new WeakMap<
223223 NormalizedPropsOptions
224224> ( )
225225
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+
226235function normalizePropsOptions (
227236 raw : ComponentPropsOptions | void
228237) : NormalizedPropsOptions {
@@ -240,10 +249,8 @@ function normalizePropsOptions(
240249 warn ( `props must be strings when using array syntax.` , raw [ i ] )
241250 }
242251 const normalizedKey = camelize ( raw [ i ] )
243- if ( normalizedKey [ 0 ] !== '$' ) {
252+ if ( validatePropName ( normalizedKey ) ) {
244253 options [ normalizedKey ] = EMPTY_OBJ
245- } else if ( __DEV__ ) {
246- warn ( `Invalid prop name: "${ normalizedKey } " is a reserved property.` )
247254 }
248255 }
249256 } else {
@@ -252,7 +259,7 @@ function normalizePropsOptions(
252259 }
253260 for ( const key in raw ) {
254261 const normalizedKey = camelize ( key )
255- if ( normalizedKey [ 0 ] !== '$' ) {
262+ if ( validatePropName ( normalizedKey ) ) {
256263 const opt = raw [ key ]
257264 const prop : NormalizedProp = ( options [ normalizedKey ] =
258265 isArray ( opt ) || isFunction ( opt ) ? { type : opt } : opt )
@@ -267,8 +274,6 @@ function normalizePropsOptions(
267274 needCastKeys . push ( normalizedKey )
268275 }
269276 }
270- } else if ( __DEV__ ) {
271- warn ( `Invalid prop name: "${ normalizedKey } " is a reserved property.` )
272277 }
273278 }
274279 }
0 commit comments