MCPcopy
hub / github.com/vuejs/core / mergeDefaults

Function mergeDefaults

packages/runtime-core/src/apiSetupHelpers.ts:450–474  ·  view source on GitHub ↗
(
  raw: ComponentPropsOptions,
  defaults: Record<string, any>,
)

Source from the content-addressed store, hash-verified

448 * @internal
449 */
450export 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.

Callers 1

Calls 3

isFunctionFunction · 0.90
warnFunction · 0.90
normalizePropsOrEmitsFunction · 0.85

Tested by

no test coverage detected