CONFIG_PRODUCTION_TIP = 'CONFIG_PRODUCTION_TIP',
CONFIG_IGNORED_ELEMENTS = 'CONFIG_IGNORED_ELEMENTS',
CONFIG_WHITESPACE = 'CONFIG_WHITESPACE',
+ CONFIG_OPTION_MERGE_STRATS = 'CONFIG_OPTION_MERGE_STRATS',
INSTANCE_SET = 'INSTANCE_SET',
INSTANCE_DELETE = 'INSTANCE_DELETE',
`\`config.compilerOptions.whitespace\`.`
},
+ [DeprecationTypes.CONFIG_OPTION_MERGE_STRATS]: {
+ message:
+ `config.optionMergeStrategies no longer exposes internal strategies. ` +
+ `Use custom merge functions instead.`
+ },
+
[DeprecationTypes.INSTANCE_SET]: {
message:
`vm.$set() has been removed as it is no longer needed in Vue 3. ` +
import { nextTick } from '../scheduler'
import { version } from '..'
import {
- installLegacyConfigProperties,
+ installLegacyConfigWarnings,
+ installLegacyOptionMergeStrats,
LegacyConfig,
legacyOptionMergeStrats
} from './globalConfig'
render: RootRenderFunction
) {
installFilterMethod(app, context)
+ installLegacyOptionMergeStrats(app.config)
if (!singletonApp) {
// this is the call of creating the singleton itself so the rest is
installCompatMount(app, context, render)
installLegacyAPIs(app)
applySingletonAppMutations(app)
- if (__DEV__) installLegacyConfigProperties(app.config)
+ if (__DEV__) installLegacyConfigWarnings(app.config)
}
function installFilterMethod(app: App, context: AppContext) {
import { extend, isArray } from '@vue/shared'
import { AppConfig } from '../apiCreateApp'
import { mergeDataOption } from './data'
-import { DeprecationTypes, warnDeprecation } from './compatConfig'
+import {
+ DeprecationTypes,
+ softAssertCompatEnabled,
+ warnDeprecation
+} from './compatConfig'
import { isCopyingConfig } from './global'
// legacy config warnings
}
// dev only
-export function installLegacyConfigProperties(config: AppConfig) {
+export function installLegacyConfigWarnings(config: AppConfig) {
const legacyConfigOptions: Record<string, DeprecationTypes> = {
silent: DeprecationTypes.CONFIG_SILENT,
devtools: DeprecationTypes.CONFIG_DEVTOOLS,
}
})
})
+}
- // Internal merge strats which are no longer needed in v3, but we need to
- // expose them because some v2 plugins will reuse these internal strats to
- // merge their custom options.
- extend(config.optionMergeStrategies, legacyOptionMergeStrats)
+export function installLegacyOptionMergeStrats(config: AppConfig) {
+ config.optionMergeStrategies = new Proxy({} as any, {
+ get(target, key) {
+ if (key in target) {
+ return target[key]
+ }
+ if (
+ key in legacyOptionMergeStrats &&
+ softAssertCompatEnabled(
+ DeprecationTypes.CONFIG_OPTION_MERGE_STRATS,
+ null
+ )
+ ) {
+ return legacyOptionMergeStrats[
+ key as keyof typeof legacyOptionMergeStrats
+ ]
+ }
+ }
+ })
}
export const legacyOptionMergeStrats = {
| GLOBAL_OBSERVABLE | ● | `Vue.observable` removed (use `reactive`) | [link](https://v3.vuejs.org/api/basic-reactivity.html) |
| CONFIG_KEY_CODES | ● | config.keyCodes rmeoved | [link](https://v3.vuejs.org/guide/migration/keycode-modifiers.html) |
| CONFIG_WHITESPACE | ● | In Vue 3 whitespace defaults to `"condense"` | |
+| CONFIG_OPTION_MERGE_STRATS | ● | Vue 3 no longer exposes internal option merge strats | |
| INSTANCE_SET | ● | `vm.$set` removed (no longer needed) | |
| INSTANCE_DELETE | ● | `vm.$delete` removed (no longer needed) | |
| INSTANCE_EVENT_EMITTER | ● | `vm.$on`, `vm.$off`, `vm.$once` removed | [link](https://v3.vuejs.org/guide/migration/events-api.html) |
import Vue from '@vue/compat'
-import { toggleDeprecationWarning } from '../../runtime-core/src/compat/compatConfig'
+import {
+ DeprecationTypes,
+ toggleDeprecationWarning
+} from '../../runtime-core/src/compat/compatConfig'
import { createApp } from '../src/esm-index'
import { triggerEvent } from './utils'
}).mount(el)
expect(el.innerHTML).toBe(`<v-foo></v-foo><foo></foo>`)
})
+
+test('config.optionMergeStrategies', () => {
+ toggleDeprecationWarning(true)
+ expect(typeof Vue.config.optionMergeStrategies.created).toBe('function')
+ expect(DeprecationTypes.CONFIG_OPTION_MERGE_STRATS).toHaveBeenWarned()
+})