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

Function mergeOptions

packages/runtime-core/src/componentOptions.ts:969–1003  ·  view source on GitHub ↗
(
  to: any,
  from: any,
  strats: Record<string, OptionMergeFunction>,
  asMixin = false,
)

Source from the content-addressed store, hash-verified

967}
968
969export function mergeOptions(
970 to: any,
971 from: any,
972 strats: Record<string, OptionMergeFunction>,
973 asMixin = false,
974): any {
975 if (__COMPAT__ && isFunction(from)) {
976 from = from.options
977 }
978
979 const { mixins, extends: extendsOptions } = from
980
981 if (extendsOptions) {
982 mergeOptions(to, extendsOptions, strats, true)
983 }
984 if (mixins) {
985 mixins.forEach((m: ComponentOptionsMixin) =>
986 mergeOptions(to, m, strats, true),
987 )
988 }
989
990 for (const key in from) {
991 if (asMixin && key === 'expose') {
992 __DEV__ &&
993 warn(
994 `"expose" option is ignored when declared in mixins or extends. ` +
995 `It should only be declared in the base component itself.`,
996 )
997 } else {
998 const strat = internalOptionMergeStrats[key] || (strats && strats[key])
999 to[key] = strat ? strat(to[key], from[key]) : from[key]
1000 }
1001 }
1002 return to
1003}
1004
1005export const internalOptionMergeStrats: Record<string, Function> = {
1006 data: mergeDataFn,

Callers 4

SubVueFunction · 0.90
extendCtorFunction · 0.90
createCompatVueFunction · 0.90
resolveMergedOptionsFunction · 0.85

Calls 3

isFunctionFunction · 0.90
warnFunction · 0.90
forEachMethod · 0.80

Tested by

no test coverage detected