Skip to content

Commit

Permalink
fix(runtime-core): properly merge unmounted and beforeUnmount options (
Browse files Browse the repository at this point in the history
  • Loading branch information
laineus committed Sep 1, 2021
1 parent 6f555cf commit 741d3b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/runtime-core/__tests__/apiOptions.spec.ts
Expand Up @@ -1265,14 +1265,22 @@ describe('api: options', () => {

test('this.$options[lifecycle-name]', () => {
const mixin = {
mounted() {}
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)
},
render: () => null
}).mount(nodeOps.createElement('div'))
Expand Down
2 changes: 2 additions & 0 deletions packages/runtime-core/src/componentOptions.ts
Expand Up @@ -1015,7 +1015,9 @@ export const internalOptionMergeStrats: Record<string, Function> = {
beforeUpdate: mergeAsArray,
updated: mergeAsArray,
beforeDestroy: mergeAsArray,
beforeUnmount: mergeAsArray,
destroyed: mergeAsArray,
unmounted: mergeAsArray,
activated: mergeAsArray,
deactivated: mergeAsArray,
errorCaptured: mergeAsArray,
Expand Down

0 comments on commit 741d3b3

Please sign in to comment.