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

Pass down route props to $attrs #1695

Closed
posva opened this issue Aug 22, 2017 · 2 comments
Closed

Pass down route props to $attrs #1695

posva opened this issue Aug 22, 2017 · 2 comments

Comments

@posva
Copy link
Member

posva commented Aug 22, 2017

Version

2.7.0

Reproduction link

https://www.webpackbin.com/bins/-Ks8plb2Lsqpt8Po3Rxg

Steps to reproduce

Click on the different links

What is expected?

Passing props in the route object:

{ path: '/', component: Hello, props: { name: 'world' }},

should appear in $attrs as long as name is not declared as a prop in Hello.vue

What is actually happening?

no prop


moved from vuejs/vue#6426

@posva
Copy link
Member Author

posva commented Aug 22, 2017

I haven't dived in already but it may be at this line: https://github.com/vuejs/vue-router/blob/dev/src/components/view.js#L71

@lbogdan
Copy link
Contributor

lbogdan commented Aug 22, 2017

I did some debugging and found that the issue is in the <router-view> component: it takes the params in the route and sends them to the route component verbatim, in props, without checking if they are defined or not on the component (which was normal behavior before the introduction of $attrs in vue 2.4.0).
What it should do instead is passing the defined props in props, and the rest in attrs.

lbogdan added a commit to lbogdan/vue-router that referenced this issue Aug 25, 2017
lbogdan added a commit to lbogdan/vue-router that referenced this issue Aug 25, 2017
lbogdan added a commit to lbogdan/vue-router that referenced this issue Sep 1, 2017
lbogdan added a commit to lbogdan/vue-router that referenced this issue Sep 1, 2017
yyx990803 pushed a commit that referenced this issue Oct 11, 2017
…1695. (#1702)

* Added repro test for #1695.

* Send props not defined on the route component in $attrs.
Fixes #1695.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants