@@ -563,26 +563,30 @@ export function normalizePropsOptions(
563
563
const prop : NormalizedProp = ( normalized [ normalizedKey ] =
564
564
isArray ( opt ) || isFunction ( opt ) ? { type : opt } : extend ( { } , opt ) )
565
565
const propType = prop . type
566
+ let shouldCast = false
566
567
let shouldCastTrue = true
567
568
568
- const checkForBoolean = (
569
- type : PropConstructor | true | null | undefined ,
570
- ) => {
571
- const typeName = isFunction ( type ) && type . name
572
-
573
- // If we find `String` before `Boolean`, e.g. `[String, Boolean]`, we need to handle the casting slightly
574
- // differently. Props passed as `<Comp checked="">` or `<Comp checked="checked">` will either be treated as
575
- // strings or converted to a boolean `true`, depending on the order of the types.
576
- if ( typeName === 'String' ) {
577
- shouldCastTrue = false
569
+ if ( isArray ( propType ) ) {
570
+ for ( let index = 0 ; index < propType . length ; ++ index ) {
571
+ const type = propType [ index ]
572
+ const typeName = isFunction ( type ) && type . name
573
+
574
+ if ( typeName === 'Boolean' ) {
575
+ shouldCast = true
576
+ break
577
+ } else if ( typeName === 'String' ) {
578
+ // If we find `String` before `Boolean`, e.g. `[String, Boolean]`,
579
+ // we need to handle the casting slightly differently. Props
580
+ // passed as `<Comp checked="">` or `<Comp checked="checked">`
581
+ // will either be treated as strings or converted to a boolean
582
+ // `true`, depending on the order of the types.
583
+ shouldCastTrue = false
584
+ }
578
585
}
579
-
580
- return typeName === 'Boolean'
586
+ } else {
587
+ shouldCast = isFunction ( propType ) && propType . name === 'Boolean'
581
588
}
582
589
583
- const shouldCast = isArray ( propType )
584
- ? propType . some ( checkForBoolean )
585
- : checkForBoolean ( propType )
586
590
prop [ BooleanFlags . shouldCast ] = shouldCast
587
591
prop [ BooleanFlags . shouldCastTrue ] = shouldCastTrue
588
592
// if the prop needs boolean casting or default value
0 commit comments