From f6c6776664de111fcf05eb2512e691274ec97b3b Mon Sep 17 00:00:00 2001 From: nkitamura Date: Thu, 26 Aug 2021 10:09:51 +0900 Subject: [PATCH 1/3] fix(runtime-core): add merge strats for unmounted and beforeUnmounted --- packages/runtime-core/src/componentOptions.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index db12bfbcf51..41e02c5da0a 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -1015,7 +1015,9 @@ export const internalOptionMergeStrats: Record = { beforeUpdate: mergeAsArray, updated: mergeAsArray, beforeDestroy: mergeAsArray, + beforeUnmount: mergeAsArray, destroyed: mergeAsArray, + unmounted: mergeAsArray, activated: mergeAsArray, deactivated: mergeAsArray, errorCaptured: mergeAsArray, From 88ecea92ee070e6283c0f0a25efb1073e8512922 Mon Sep 17 00:00:00 2001 From: nkitamura Date: Thu, 26 Aug 2021 17:56:45 +0900 Subject: [PATCH 2/3] test: add case for options merge strategies --- packages/runtime-core/__tests__/apiOptions.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/__tests__/apiOptions.spec.ts b/packages/runtime-core/__tests__/apiOptions.spec.ts index 9c50664b786..7286c657b4b 100644 --- a/packages/runtime-core/__tests__/apiOptions.spec.ts +++ b/packages/runtime-core/__tests__/apiOptions.spec.ts @@ -1265,14 +1265,18 @@ describe('api: options', () => { test('this.$options[lifecycle-name]', () => { const mixin = { - mounted() {} + mounted() {}, + unmounted() {} } createApp({ mixins: [mixin], mounted() {}, + unmounted() {}, created() { expect(this.$options.mounted).toBeInstanceOf(Array) expect(this.$options.mounted.length).toBe(2) + expect(this.$options.unmounted).toBeInstanceOf(Array) + expect(this.$options.unmounted.length).toBe(2) }, render: () => null }).mount(nodeOps.createElement('div')) From 4681a79a793774defeb49ff184bb9ed05d82a167 Mon Sep 17 00:00:00 2001 From: nkitamura Date: Thu, 26 Aug 2021 20:16:38 +0900 Subject: [PATCH 3/3] test: add case for merge strat for beforeUnmount --- packages/runtime-core/__tests__/apiOptions.spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/runtime-core/__tests__/apiOptions.spec.ts b/packages/runtime-core/__tests__/apiOptions.spec.ts index 7286c657b4b..0dda6426565 100644 --- a/packages/runtime-core/__tests__/apiOptions.spec.ts +++ b/packages/runtime-core/__tests__/apiOptions.spec.ts @@ -1266,15 +1266,19 @@ describe('api: options', () => { test('this.$options[lifecycle-name]', () => { const mixin = { mounted() {}, + beforeUnmount() {}, unmounted() {} } createApp({ mixins: [mixin], mounted() {}, + beforeUnmount() {}, unmounted() {}, created() { expect(this.$options.mounted).toBeInstanceOf(Array) 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) },