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

vNode hooks are not triggering if a component does not have any props declared #684

Closed
CyberAP opened this issue Feb 3, 2020 · 2 comments

Comments

@CyberAP
Copy link
Contributor

CyberAP commented Feb 3, 2020

Version

3.0.0-alpha.4

Reproduction link

JSFiddle

Steps to reproduce

  1. Define a component with no props
  2. Use that component as a child of another component
  3. Set up some action on vNode hook, for example: @vnodeMounted="onMounted"
  4. Hook is not triggering until child component has any props declared

What is expected?

Hooks should be working without declaring any props

@yyx990803 yyx990803 added the 🐞 bug Something isn't working label Feb 3, 2020
underfin added a commit to underfin/vue-next that referenced this issue Feb 4, 2020
@yyx990803 yyx990803 removed the 🐞 bug Something isn't working label Feb 4, 2020
underfin added a commit to underfin/vue-next that referenced this issue Feb 4, 2020
@yyx990803
Copy link
Member

yyx990803 commented Feb 7, 2020

Hmm, maybe we should rename the vnodeXXX hooks to elementXXX, since they are actually designed for working with DOM elements (and is the underlying mechanism for directives).

When used on a component, they are passed down to the component as part of $attrs, and automatically spread on to the child component root when the child component has declared props. This is what enables usage of a directive on a component - e.g. <Foo v-show="ok"/>.

The thing to note here is that a component with optional props doesn't perform the auto-spread behavior. I think this could be confusing so we may want to rethink that behavior.

@CyberAP
Copy link
Contributor Author

CyberAP commented Feb 7, 2020

I personally would find it very useful for hooks to not contain any information of what they are related to and use them directly, like this:

<FooBar @mounted="onFooBarMounted" />

This goes on par with the component options and does not conflict with them since they're prefixed with on.

I don't know much about native vue renderers, but I'm pretty sure there's no such concept as element there.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants