linkedom icon indicating copy to clipboard operation
linkedom copied to clipboard

HTMLSlotElement.assignedNodes()

Open thepassle opened this issue 2 years ago • 4 comments

Currently HTMLSlotElement.assignedNodes() doesn't seem to be supported, I have a couple of components that I'd like to SSR that make use of this API. Do you think assignedNodes() could at some point be supported?

thepassle avatar Apr 22 '22 11:04 thepassle

ShadowDOM is still not SSR friendly… once it is, stuff related to SSR will land, in a way or another, but so far I never cared about ShadowDOM even on the client side (it’s not needed) so don’t expect much to work.

PRs welcome though 👍

WebReflection avatar Apr 22 '22 12:04 WebReflection

so don’t expect much to work.

Most of the custom elements ive SSRed that use shadow dom seem to work fine 🙂 Im just missing assignedNodes on the slot element

Ill try and see about making a PR, thanks

thepassle avatar Apr 22 '22 12:04 thepassle

DSD is not out though, or is it? That’s what I meant (Declarative ShadowDOM)

WebReflection avatar Apr 22 '22 12:04 WebReflection

Hmm I was hoping that this would only be a small change to HTMLSlotElement by adding the assignedNodes() method, but it looks like this.shadowRoot.querySelector('slot') doesnt actually return a HTMLSlotElement, but an Element, and it seems like all elements have the same nodeType. Im not sure if I'll be able to contribute that

thepassle avatar Apr 22 '22 12:04 thepassle

@thepassle sorry for late reply ... you need to register special elements otherwise these are created as Element instances ... see any registered element to understand how that's done, the Options is the latest that got added: https://github.com/WebReflection/linkedom/commit/155dfb9de84c672a0b2f4476d14f68d4b9a5054e

WebReflection avatar Oct 27 '22 20:10 WebReflection

added this to my branch https://github.com/WebReflection/linkedom/compare/main...luwes:linkedom:wesc?expand=1#diff-5ade2633056d4de7ec79588b01256021baa9de705796a309e7cfda73e9b25d7d

let me know if you're interested, I can open a PR

luwes avatar Jun 10 '23 19:06 luwes

haven't checked but as I don't care/need Shadow DOM too much and it's not (I hope) on any critical perf path, feel free to open that PR, thanks!

WebReflection avatar Jun 10 '23 19:06 WebReflection

That would still be helpful to me @luwes , so id be very appreciative if you could make that PR :)

thepassle avatar Jun 10 '23 20:06 thepassle

I would love to have this as well. It is impossible to use custom elements without needing ShadowDOM. If you do composition in any other framework (props.children in React/Preact/Solid, slots in Vue/Svelte, etc), then you need ShadowDOM for the same (highly useful!) patterns with custom elements.

trusktr avatar Jun 15 '23 18:06 trusktr

Folks I’m afraid life happens and extra time for stuff I don’t need/use daily, even for reviews I’d love to merge, is super hard to find. I’ll do my best to follow up on this whenever I can put my brain and eyes on it, and as ETA that’s not likely going to happen before the end of the month, but I’ll try any weekend I can.

WebReflection avatar Jun 15 '23 19:06 WebReflection

@WebReflection

Could please take a look at the already provided PR (#209) for this issue.

IMHO it's a very important improvement, because many of us want to utilize linkedom mainly for SSR rendering of Custom Elements and all its horrible obstacles in a sufficient standard compliant manner.

Sure, there are other workarounds possible and few forks including this patch are also available. Nevertheless. I would highly appreciate a more proper solution, which keeps bug reports, continuous improvements and reliable maintenance at solely one well known place together.

mash-graz avatar Oct 18 '23 23:10 mash-graz

I'm still very busy ... I'll try to merge after review some PR over the weekend

WebReflection avatar Oct 19 '23 12:10 WebReflection

... I'll try to merge after review some PR over the weekend

Thank you for your pleasant reply!

mash-graz avatar Oct 19 '23 23:10 mash-graz