-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Recursive compontent that emits cannot be created #3361
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
Comments
Thanks for the information! I thought that solution (re-emitting event TL;DR; If you use ES6 and have strict mode on, Tail Call Optimization is used. Essentially it changes a returning function call at the end of a function into a jump. However, the system still emits (potentially many times) events decreasing performance. |
Yeah, I did also aware of the problem. I think I should reopen this issue for further discussion. |
Hi,
is this correct? |
Version
3.0.7
Reproduction link
https://codesandbox.io/s/recursive-emit-bug-10073
Steps to reproduce
See codesandbox for illustration of the problem
$emit("event", depth)
from recursive componentv-bind="$attrs"
to every recursive inclusion from recursive component to enable emitting from any level@event="..."
handlerWhat is expected?
The
@event="..."
is called for any "depth"What is actually happening?
Only the first (top level) of the recursive component is handled
I spent some hours debugging this issue. According to documents we should add
emits: ["<name>"]
to our components. However, by doing so, we capture the event listener and effectively remove it from$attrs
at the first "level".The system behaves according to specifications, but it feels wrong to have to leave out
emits: ["<name>"]
when you build an emitting recursive component. At least for me it was very counter-intuitive.Sadly I do not have a good solution as I understand why you capture any defined props and emits from the
$attrs
. However, maybe I am just not doing it right, would love to hear how we should create an emitting recursive component.P.S. I found this problem when I was creating a file explorer component using a single recursive component.
The text was updated successfully, but these errors were encountered: