Support nested elements on @child and @children
I'm submitting a feature request
Current behavior:
@children and @child select immediate children only.
- What is the expected behavior?
@children and @child should select arbitrary nested children.
- What is the motivation / use case for changing the behavior?
This is a great and important feature, and it is a shame that it boxes you into structuring your markup a particular way.
If the reason for limiting to immediate children was performance, this could be configurable:
@children('my-element') a; // immediate children
@children({ selector: 'my-element', recursive: true }) b; // all children
https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver Could directly map to 'subtree' option Recursive is not expected in context of dom/css i guess. Thought to write recursive is not right.. but then thought about file systems.. and yeah it is right word.. just not in context of css selectors (-:
@bigopon thoughts?
#590 is the issue related to @children. It will cause the <slot/> and @children not working properly together. This feature, theoretically, can work without that fix, as you can target its own content, but I think it's better to wait for that fix to be merged / discussed before we go ahead with this. I'm not sure what we would do in recursive case though ? do we count them as 1, or 1 + all children with the same selector ?
fix #590 is waiting for @jdanyow @EisenbergEffect 's review
I'm not sure what we would do in recursive case though ? do we count them as 1, or 1 + all children with the same selector ?
I don't follow. @children('foo') should be populated with an array of 3 FooCustomElement for the following view:
<template>
<foo></foo>
<ul>
<li><foo></foo></li>
</ul>
<foo></foo>
</template>
if we have something like this rendered
<app>
<tree>
<tree-node>
<tree>
<tree-node>...</tree-node>
</tree>
</tree-node>
</app>
What would @children('tree-node') return ?
On app, an array of two TreeNodeCustomElements.
Since #590 is closed, can this be closed as well?