fix(runtime-core): properly merge unmounted and beforeUnmount options (#4447)
This commit is contained in:
parent
6f555cf98c
commit
741d3b36f2
@ -1265,14 +1265,22 @@ describe('api: options', () => {
|
|||||||
|
|
||||||
test('this.$options[lifecycle-name]', () => {
|
test('this.$options[lifecycle-name]', () => {
|
||||||
const mixin = {
|
const mixin = {
|
||||||
mounted() {}
|
mounted() {},
|
||||||
|
beforeUnmount() {},
|
||||||
|
unmounted() {}
|
||||||
}
|
}
|
||||||
createApp({
|
createApp({
|
||||||
mixins: [mixin],
|
mixins: [mixin],
|
||||||
mounted() {},
|
mounted() {},
|
||||||
|
beforeUnmount() {},
|
||||||
|
unmounted() {},
|
||||||
created() {
|
created() {
|
||||||
expect(this.$options.mounted).toBeInstanceOf(Array)
|
expect(this.$options.mounted).toBeInstanceOf(Array)
|
||||||
expect(this.$options.mounted.length).toBe(2)
|
expect(this.$options.mounted.length).toBe(2)
|
||||||
|
expect(this.$options.beforeUnmount).toBeInstanceOf(Array)
|
||||||
|
expect(this.$options.beforeUnmount.length).toBe(2)
|
||||||
|
expect(this.$options.unmounted).toBeInstanceOf(Array)
|
||||||
|
expect(this.$options.unmounted.length).toBe(2)
|
||||||
},
|
},
|
||||||
render: () => null
|
render: () => null
|
||||||
}).mount(nodeOps.createElement('div'))
|
}).mount(nodeOps.createElement('div'))
|
||||||
|
@ -1015,7 +1015,9 @@ export const internalOptionMergeStrats: Record<string, Function> = {
|
|||||||
beforeUpdate: mergeAsArray,
|
beforeUpdate: mergeAsArray,
|
||||||
updated: mergeAsArray,
|
updated: mergeAsArray,
|
||||||
beforeDestroy: mergeAsArray,
|
beforeDestroy: mergeAsArray,
|
||||||
|
beforeUnmount: mergeAsArray,
|
||||||
destroyed: mergeAsArray,
|
destroyed: mergeAsArray,
|
||||||
|
unmounted: mergeAsArray,
|
||||||
activated: mergeAsArray,
|
activated: mergeAsArray,
|
||||||
deactivated: mergeAsArray,
|
deactivated: mergeAsArray,
|
||||||
errorCaptured: mergeAsArray,
|
errorCaptured: mergeAsArray,
|
||||||
|
Loading…
Reference in New Issue
Block a user