dom icon indicating copy to clipboard operation
dom copied to clipboard

Which target could we expose in Event Timing?

Open npm1 opened this issue 5 years ago • 6 comments

This is not an issue, but rather requesting some help to figure out how to integrate a new feature of Event Timing properly with DOM. We'd like to add the event's target to improve attribution of the API: see https://github.com/WICG/event-timing/issues/9 or https://github.com/WICG/event-timing/issues/60. I'm aware that we should only expose the 'top-level' Event target: if an event is re-targeted and there are targets in shadow DOM then those won't be exposed. However, I'm having a hard time parsing the event dispatch algorithm to understand which is the target I'd like. Is https://dom.spec.whatwg.org/#concept-event-dispatch only called once per event (and re-targeting happens internally), and hence target the object I want?

npm1 avatar Feb 28 '20 21:02 npm1

I don't think you've given enough information. To answer this one would need to know at least:

  • Which events?
  • How are they dispatched? (I.e., with what settings.)
  • How are they meant to be exposed? (Timing, place, etc.)

annevk avatar Mar 02 '20 13:03 annevk

Which events: https://wicg.github.io/event-timing/#sec-events-exposed. Note that we expose first-input (where the types are a subset of those) always, and slow events.

How are they dispatched: I don't understand this question. "They" = the events? I suspect the answer to that would be in the corresponding event's spec.

How are they meant to be exposed: similar to other performance entries, we have a PerformanceEventTiming object which is exposed on a size-bounded array on the performance timeline and exposed to a PerformanceObserver, both of which are exposed to Window. In terms of the timing, we expose once the information on the update the rendering step after event handlers have ran, so that we can expose the 'next paint' after those handlers have ran.

npm1 avatar Mar 02 '20 15:03 npm1

How they are dispatched is somewhat relevant as it could affect whether they leave the shadow tree or not. It also seems you'd have to patch all the places where they are dispatched in order to collect them for a report.

annevk avatar Mar 02 '20 16:03 annevk

That information can be obtained via event.composed, no? There's no need to patch all the places. When event.composed is false and the target is in the shadow DOM, we cannot expose a target so it should return null.

npm1 avatar Mar 02 '20 17:03 npm1

How can you collect them without patching the dispatch places?

annevk avatar Mar 04 '20 10:03 annevk

They are dispatched from the DOM event dispatch algorithm, so again, that's the only thing that needs to change. What would I need to change from, for example, https://w3c.github.io/uievents/#event-type-mousedown?

npm1 avatar Mar 04 '20 14:03 npm1