Hacker News new | ask | show | jobs
by logankeenan 1253 days 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
1 comments

That'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.
Yea, that’s been my biggest problem. The target is now different, so I can’t call event.target.value
Right, if you want `value` to be part of the public interface of your component you need to add a value property to expose it.