You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I did the original Legacy Types definitions for Menu-Drop a few commits ago, I had to change the component's Shadow Root event listeners over to ones bound to the component itself, as TypeScript didn't like me having events added to the Shadow Root.
Turns out this is because the events are receivable on the Shadow Root because of event bubbling, rather than being dispatched directly to the Shadow Root itself. TypeScript (nor the MDN docs) mention this as an option to take (not that it's unrecommended, it's just not mentioned anywhere plainly as an option you *could* take), so I'm not completely sure whether this is a good practice or not.
My original thoughts were that the Shadow Root can be thought of synonymously with the `document`, and that you could listen to the same events and such, on it. But properties like `onclick` aren't present on the Shadow Root, so it's not completely the same, come to find out. It's a bit wishy washy at the moment, so I'm just tidying up the code for that here, since the original codebase relied on that being structured that way because of the event handling `event.target` logic, and adding the events to the parent component element itself prevented it from working when I changed that in the types update.
I have more info about all of this in the issues I made for it here in the Menu-Drop repo itself, and the issue I made to help think this out, over in the Better-TypeScript repo.
#1BenjaminAster/Better-TypeScript#2
Another note, this is correct in terms of TypeScript's perspective, this is not mentioned behavior anywhere in the documentation that I have seen. So it makes sense that TypeScript didn't add type definitions for Document-like event handling on Shadow Roots, because it wasn't mentioned anywhere as part of the spec (I'll need to dive into the actual spec itself, as it may actually be mentioned there. I was just talking about MDN and resources like that).
This is a mirror/reference to another issue I wrote, which relates to how Menu Drop event handling works with the component's Shadow DOM.
ShadowRoot | HTMLElement Event Handling Interchangeability
The text was updated successfully, but these errors were encountered: