( options: NormalizedProps, props: Data, key: string, value: unknown, instance: ComponentInternalInstance, isAbsent: boolean, )
| 450 | } |
| 451 | |
| 452 | function resolvePropValue( |
| 453 | options: NormalizedProps, |
| 454 | props: Data, |
| 455 | key: string, |
| 456 | value: unknown, |
| 457 | instance: ComponentInternalInstance, |
| 458 | isAbsent: boolean, |
| 459 | ) { |
| 460 | const opt = options[key] |
| 461 | if (opt != null) { |
| 462 | const hasDefault = hasOwn(opt, class="st">'default') |
| 463 | class="cm">// default values |
| 464 | if (hasDefault && value === undefined) { |
| 465 | const defaultValue = opt.default |
| 466 | if ( |
| 467 | opt.type !== Function && |
| 468 | !opt.skipFactory && |
| 469 | isFunction(defaultValue) |
| 470 | ) { |
| 471 | const { propsDefaults } = instance |
| 472 | if (key in propsDefaults) { |
| 473 | value = propsDefaults[key] |
| 474 | } else { |
| 475 | const reset = setCurrentInstance(instance) |
| 476 | value = propsDefaults[key] = defaultValue.call( |
| 477 | __COMPAT__ && |
| 478 | isCompatEnabled(DeprecationTypes.PROPS_DEFAULT_THIS, instance) |
| 479 | ? createPropsDefaultThis(instance, props, key) |
| 480 | : null, |
| 481 | props, |
| 482 | ) |
| 483 | reset() |
| 484 | } |
| 485 | } else { |
| 486 | value = defaultValue |
| 487 | } |
| 488 | class="cm">// #9006 reflect default value on custom element |
| 489 | if (instance.ce) { |
| 490 | instance.ce._setProp(key, value) |
| 491 | } |
| 492 | } |
| 493 | class="cm">// boolean casting |
| 494 | if (opt[BooleanFlags.shouldCast]) { |
| 495 | if (isAbsent && !hasDefault) { |
| 496 | value = false |
| 497 | } else if ( |
| 498 | opt[BooleanFlags.shouldCastTrue] && |
| 499 | (value === class="st">'' || value === hyphenate(key)) |
| 500 | ) { |
| 501 | value = true |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | return value |
| 506 | } |
| 507 | |
| 508 | const mixinPropsCache = new WeakMap<ConcreteComponent, NormalizedPropsOptions>() |
| 509 |
no test coverage detected