3 ms·
I evaluated web components a few months ago. Everything was great except event propagation. Let’s say I have a component which is a DIV that wraps a label and a
by logankeenan 4y ago
I evaluated web components a few months ago. Everything was great except event propagation. Let’s say I have a component which is a DIV that wraps a label and an input. How can a consumer listen to the onchange event of the component which should map to the inputs onchange event. I could never come up with a holistic solution that would work for all components. It’d require a lot manual work mapping the input event to a new event that is triggered on the web component. I’d be interested if anyone found a better pattern
- esprehn 4y agoThat's handled by shadow dom event retargeting. When the events pass over the boundary of the component the target becomes the component itself instead of the input.
- logankeenan 4y agoYea, that’s been my biggest problem. The target is now different, so I can’t call event.target.value
- esprehn 4y agoRight, if you want `value` to be part of the public interface of your component you need to add a value property to expose it.