Skip to content

Commit 741d3b3

Browse files
authored
fix(runtime-core): properly merge unmounted and beforeUnmount options (#4447)
1 parent 6f555cf commit 741d3b3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/runtime-core/__tests__/apiOptions.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,14 +1265,22 @@ describe('api: options', () => {
12651265

12661266
test('this.$options[lifecycle-name]', () => {
12671267
const mixin = {
1268-
mounted() {}
1268+
mounted() {},
1269+
beforeUnmount() {},
1270+
unmounted() {}
12691271
}
12701272
createApp({
12711273
mixins: [mixin],
12721274
mounted() {},
1275+
beforeUnmount() {},
1276+
unmounted() {},
12731277
created() {
12741278
expect(this.$options.mounted).toBeInstanceOf(Array)
12751279
expect(this.$options.mounted.length).toBe(2)
1280+
expect(this.$options.beforeUnmount).toBeInstanceOf(Array)
1281+
expect(this.$options.beforeUnmount.length).toBe(2)
1282+
expect(this.$options.unmounted).toBeInstanceOf(Array)
1283+
expect(this.$options.unmounted.length).toBe(2)
12761284
},
12771285
render: () => null
12781286
}).mount(nodeOps.createElement('div'))

packages/runtime-core/src/componentOptions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,9 @@ export const internalOptionMergeStrats: Record<string, Function> = {
10151015
beforeUpdate: mergeAsArray,
10161016
updated: mergeAsArray,
10171017
beforeDestroy: mergeAsArray,
1018+
beforeUnmount: mergeAsArray,
10181019
destroyed: mergeAsArray,
1020+
unmounted: mergeAsArray,
10191021
activated: mergeAsArray,
10201022
deactivated: mergeAsArray,
10211023
errorCaptured: mergeAsArray,

0 commit comments

Comments
 (0)