ChristophP / web-react-components

Reuse your react components, for example in Elm or any other technology by wrapping them easily into a Web Component.
58 stars 5 forks source link

Handler gets attached twice if name already exists in DOM #26

Open ChristophP opened 7 years ago

ChristophP commented 7 years ago

If you have a react property called onClick and use it on the web-react-component the handler will fire twice. Once for the native DOM and once for the web react component.

Example (logs twice when clicked):

<some-button onClick="console.log('Hello')"></some-button>

This is not an issue when attaching the handler with addEventListener though, because the DOM event would be click while the web react component event would be onClick

ChristophP commented 7 years ago

We should check the events .composed property to determine if it bubbles outside of the DOM. If not we should redispatch the event, if not just use the event which bubbles up into the light DOM.