Skip to content

Mixin guard is not called when component has same guard #1519

@nirazul

Description

@nirazul

Version

2.6.0

Reproduction link

http://jsfiddle.net/3crtn7ov/12/

Steps to reproduce

  1. Trigger all available routes

What is expected?

Mixin guard: beforeRouteUpdate should be triggered.

What is actually happening?

Mixin guard is not triggered

I initially wanted to file an issue because the beforeRouteEnter guard showed this behaviour, but I wasn't able to reproduce it within a jsfiddle. I'm quite sure that the bug affects also the other guard.

Activity

changed the title [-]Guards are not merged when using mixins[/-] [+]Guards are merged instead of called after each other when using mixins[/+] on Jun 19, 2017
changed the title [-]Guards are merged instead of called after each other when using mixins[/-] [+]Mixin guard is not called when component has same guard[/+] on Jun 19, 2017
nirazul

nirazul commented on Jun 19, 2017

@nirazul
Author

After some more debugging, I think that the other problem (beforeRouteEnter) has to do with a difference in lifecycle hook call order. What I'im unable to see is, why there is a difference in the first place...

Jsfiddle hook call order (on full reload) - works:

Cmp: beforeCreate
Cmp: created
Cmp: beforeMount
Mixin: beforeCreate
Mixin: created
Mixin: beforeMount
Mixin: mounted
Cmp: mounted
Component HOOK: beforeRouteEnter
Mixin HOOK: beforeRouteEnter
Mixin: beforeUpdate
Mixin: updated

Hook call order in my app (on full reload) - fails:

Component HOOK: beforeRouteEnter
Mixin: beforeCreate
Cmp: beforeCreate
Mixin: created
Cmp: created
Mixin: beforeMount
Cmp: beforeMount
Mixin: mounted
Cmp: mounted
Mixin: beforeUpdate
Cmp: beforeUpdate
Mixin: updated
Cmp: updated
posva

posva commented on Jun 19, 2017

@posva
Member

It looks like we forgot to add the merge strategy. For the moment, adding Vue.config.optionMergeStrategies.beforeRouteUpdate = Vue.config.optionMergeStrategies.beforeRouteEnter to your code should solve the issue
Are you using the latest versions on your project?

added a commit that references this issue on Jun 19, 2017
1ffe869
nirazul

nirazul commented on Jun 19, 2017

@nirazul
Author

@posva I'm using vue-router 2.5.3 in my app. I will check if the problem with beforeRouteEnter persists in 2.6...

nirazul

nirazul commented on Jun 26, 2017

@nirazul
Author

@posva
The second problem I mentioned seems to persist in vue-router@2.6, however there seems to be an improvement: Only the first time the route is loaded, the mixin hooks seems to fail being called, every navigation afterwards to this route calls both hooks.
I'm still trying to reproduce the error in a fiddle, but maybe that helps you pinpointing the problem in the meantime.

nirazul

nirazul commented on Jun 26, 2017

@nirazul
Author

I've found the issue to my second problem. I'm opening a second report for it.

added a commit that references this issue on Jun 29, 2017
9fde13f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @posva@nirazul

        Issue actions

          Mixin guard is not called when component has same guard · Issue #1519 · vuejs/vue-router