feat(runtime-core): support config.optionMergeStrategies
Note the behavior is different from Vue 2: - merge strategies no longer apply to built-in options. - the default value is now an empty object and no longer exposes merge strategies for built-in options.
This commit is contained in:
@@ -8,7 +8,8 @@ import {
|
||||
nextTick,
|
||||
renderToString,
|
||||
ref,
|
||||
defineComponent
|
||||
defineComponent,
|
||||
createApp
|
||||
} from '@vue/runtime-test'
|
||||
import { mockWarn } from '@vue/shared'
|
||||
|
||||
@@ -562,6 +563,28 @@ describe('api: options', () => {
|
||||
expect(serializeInner(root)).toBe(`<div>1,1,3</div>`)
|
||||
})
|
||||
|
||||
test('optionMergeStrategies', () => {
|
||||
let merged: string
|
||||
const App = defineComponent({
|
||||
render() {},
|
||||
mixins: [{ foo: 'mixin' }],
|
||||
extends: { foo: 'extends' },
|
||||
foo: 'local',
|
||||
mounted() {
|
||||
merged = this.$options.foo
|
||||
}
|
||||
})
|
||||
|
||||
const app = createApp(App)
|
||||
app.mixin({
|
||||
foo: 'global'
|
||||
})
|
||||
app.config.optionMergeStrategies.foo = (a, b) => (a ? `${a},` : ``) + b
|
||||
|
||||
app.mount(nodeOps.createElement('div'))
|
||||
expect(merged!).toBe('global,extends,mixin,local')
|
||||
})
|
||||
|
||||
describe('warnings', () => {
|
||||
mockWarn()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user