A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
When I’m listening for the slotchange event I often like to delegate it to the shadow root, especially if I have a dynamic number of slots (see example pattern in this blog post). In a nutshell you achieve this with this pattern:
The slotchange event isn’t composed by default (i.e. won’t traverse the shadow DOM) so I can’t put it on the host element with the @Listen decorator. However slotchangedoesbubble to the top of the shadow DOM by default. It would be nice if we could take advantage of that by simply specifing the shadow root as a target in the @Listen decorator. This gives us a lot nicer pattern:
Stencil version:
I'm submitting a:
[ ] bug report [x] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/
Current behavior:
When I’m listening for the
slotchange
event I often like to delegate it to the shadow root, especially if I have a dynamic number of slots (see example pattern in this blog post). In a nutshell you achieve this with this pattern:Expected behavior:
The
slotchange
event isn’t composed by default (i.e. won’t traverse the shadow DOM) so I can’t put it on the host element with the@Listen
decorator. Howeverslotchange
does bubble to the top of the shadow DOM by default. It would be nice if we could take advantage of that by simply specifing the shadow root as a target in the@Listen
decorator. This gives us a lot nicer pattern:Note that this would be especially useful for the
slotchange
event, but can be useful for any non-composed events.Steps to reproduce:
Related code:
(see above)
Other information: