( to: any, from: any, strats: Record<string, OptionMergeFunction>, asMixin = false, )
| 967 | } |
| 968 | |
| 969 | export 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 | |
| 1005 | export const internalOptionMergeStrats: Record<string, Function> = { |
| 1006 | data: mergeDataFn, |
no test coverage detected