- From: Keith Cirkel <notifications@github.com>
- Date: Thu, 05 Jun 2025 04:37:47 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/pull/1377/c2943835301@github.com>
keithamus left a comment (whatwg/dom#1377) This concept of re-despatching on the host might have confusing consequences for developers, who will be able to observe events pointed at a target that would commonly dispatch those events, but weren't the source of _this_ event. For example: ```html <button id=b>Hover me</button> <div id=popoverA popover> <template shadowrootmode=open> <div id=popoverB popover> </div> </template> </div> <script> let popoverB = popoverA.shadowRoot.querySelector('#popoverB'); b.addEventListener('mouseover', () => { popoverB.showPopover({source:b}); }); b.addEventListener('mouseout', () => { popoverB.hidePopover({source:b}); }); </script> ``` AIUI, In this example, when popoverB is shown it will dispatch a `beforetoggle` (and `toggle`) event on `popoverB`, with a source of `b`. The event will then _also_ dispatch on `popoverA`, despite the fact that `popoverA` isn't being shown. Further to that, the event being dispatched on `popoverA` would be otherwise identical to an event that `popoverA` might dispatch - for example the `target`, `source`, `isTrusted`, `composed` fields etc would all be the same. This feels like it could make it extremely difficult for developers to ascertain when an event has been dispatched because a host element has/is changed/changing state, or whether one of its shadow descendants happened to do change state and the `source` element is causing it to re-despatch. I think for this to move forward it would probably need some kind of additional property on Events, like `.wasOriginallyDespatchedInTheTargetsShadowButNowIsBeingRedespatchedInThisTreeBecauseYourSourceElementMightWantToKnowAboutIt`. Though I'm not sold on the name; maybe it can be workshopped. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/pull/1377#issuecomment-2943835301 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/pull/1377/c2943835301@github.com>
Received on Thursday, 5 June 2025 11:37:51 UTC