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

Support nested elements on @child and @children #604

Open
davismj opened this issue Mar 7, 2018 · 7 comments
Open

Support nested elements on @child and @children #604

davismj opened this issue Mar 7, 2018 · 7 comments

Comments

@davismj
Copy link
Member

davismj commented Mar 7, 2018

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
@Alexander-Taran
Copy link

Alexander-Taran commented Mar 7, 2018

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 (-:

@davismj
Copy link
Member Author

davismj commented Mar 21, 2018

@bigopon thoughts?

@bigopon
Copy link
Member

bigopon commented Mar 21, 2018

#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

@davismj
Copy link
Member Author

davismj commented Mar 21, 2018

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>

@bigopon
Copy link
Member

bigopon commented Mar 21, 2018

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 ?

@davismj
Copy link
Member Author

davismj commented Mar 21, 2018

On app, an array of two TreeNodeCustomElements.

@tmueller
Copy link

Since #590 is closed, can this be closed as well?

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

4 participants