( raw: ComponentPropsOptions, defaults: Record<string, any>, )
| 448 | * @internal |
| 449 | */ |
| 450 | export function mergeDefaults( |
| 451 | raw: ComponentPropsOptions, |
| 452 | defaults: Record<string, any>, |
| 453 | ): ComponentObjectPropsOptions { |
| 454 | const props = normalizePropsOrEmits(raw) |
| 455 | for (const key in defaults) { |
| 456 | if (key.startsWith('__skip')) continue |
| 457 | let opt = props[key] |
| 458 | if (opt) { |
| 459 | if (isArray(opt) || isFunction(opt)) { |
| 460 | opt = props[key] = { type: opt, default: defaults[key] } |
| 461 | } else { |
| 462 | opt.default = defaults[key] |
| 463 | } |
| 464 | } else if (opt === null) { |
| 465 | opt = props[key] = { default: defaults[key] } |
| 466 | } else if (__DEV__) { |
| 467 | warn(`props default key "${key}" has no corresponding declaration.`) |
| 468 | } |
| 469 | if (opt && defaults[`__skip_${key}`]) { |
| 470 | opt.skipFactory = true |
| 471 | } |
| 472 | } |
| 473 | return props |
| 474 | } |
| 475 | |
| 476 | /** |
| 477 | * Runtime helper for merging model declarations. |
no test coverage detected