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

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

Closed
nirazul opened this issue Jun 19, 2017 · 5 comments
Closed

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

nirazul opened this issue Jun 19, 2017 · 5 comments
Labels

Comments

@nirazul
Copy link

nirazul commented Jun 19, 2017

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.

@nirazul nirazul changed the title Guards are not merged when using mixins Guards are merged instead of called after each other when using mixins Jun 19, 2017
@nirazul nirazul 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 Jun 19, 2017
@nirazul
Copy link
Author

nirazul commented Jun 19, 2017

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
Copy link
Member

posva commented Jun 19, 2017

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?

@nirazul
Copy link
Author

nirazul commented Jun 19, 2017

@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
Copy link
Author

nirazul commented Jun 26, 2017

@posva
The second problem I mentioned seems to persist in [email protected], 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
Copy link
Author

nirazul commented Jun 26, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants