Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mixins): merge unmounted and beforeUnmount options #4447

Merged
merged 3 commits into from
Sep 1, 2021

Conversation

laineus
Copy link
Contributor

@laineus laineus commented Aug 26, 2021

Issue

unmounted and beforeUnmounted options will not be merged and never be called.

Demo

Codepen: https://codepen.io/laineus/pen/qBjEggq

<template>
  <ul id="app">
    <li>created: {{ $options.created }}</li><!-- ⭕Array -->
    <li>mounted: {{ $options.mounted }}</li><!-- ⭕Array -->
    <li>unmounted: {{ $options.unmounted }}</li><!-- ❌Function -->
    <li>beforeUnmounted: {{ $options.beforeUnmounted }}</li><!-- ❌Function -->
  </ul>
</template>

<script>
export default {
  created () {},
  mounted () {},
  unmounted () {},
  beforeUnmounted () {},
  mixins: [
    {
      created () {},
      mounted () {},
      unmounted () {}, // Will not be called
      beforeUnmounted () {} // Will not be called
    }
  ]
}
</script>

Version

v3.1.0-beta.7 to latest (v3.2.6) -> happens
v3.1.0-beta.6 or lower -> ok

related commit: e2ca67b#diff-bef066f3036cebd9b6db8a01d40f6eb0fdfe71c06da414b7d226652c016d7efdR982

It seems just forgotten to add global merge strategies for unmounted and beforeUnmounted.

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests?

@laineus
Copy link
Contributor Author

laineus commented Aug 26, 2021

@posva
I have added one case into existing test. 88ecea9
It will not be passed on master, and will be passed on this PR.

I figured it's not need cases for all options, so I didn't.

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeUnmount should be added too

@laineus
Copy link
Contributor Author

laineus commented Aug 26, 2021

@posva I have added for beforeUnmount too.
It passed properly on my local.

Could you check it again?

@posva posva changed the title Fix: Parent's some options will not be merged fix(mixins): merge unmounted and beforeUnmount options Aug 26, 2021
@yyx990803 yyx990803 merged commit 741d3b3 into vuejs:master Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants