Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Intent to implement and ship: constructible EventTarget

136 views
Skip to first unread message

Boris Zbarsky

unread,
Nov 18, 2017, 10:55:55 PM11/18/17
to
Summary: Make it possible for web pages to do |new EventTarget|, and
more importantly to create EventTarget subclasses like |class MyThing
extends EventTarget| that can then have DOM events dispatched on them in
the normal way, have event listeners registered with all the features
browsers support (e.g. { once: true }), etc.

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1379688

Spec: https://dom.spec.whatwg.org/#dom-eventtarget-eventtarget

Target release: 59

Preference behind which this is implemented: None.

Enabled in sandboxed iframes: Yes.

Devtools bug: I don't think devtools need to do anything special here.

Support in other browsers:

* Chrome: intent to ship thread is at
<https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/fKk4d_Vj080>
and the code landed (see
<https://bugs.chromium.org/p/chromium/issues/detail?id=740576>).
* Safari: no signals.
* Edge: no signals.

Tests: We have web platform tests for this.

Spec stability: Pretty stable. This is a very simple feature with a
simple spec, since it's just exposing an underlying well-specced and
well-tested primitive.

Security/privacy concerns: None that I know of.

Use cases: See summary.

Example use:
https://github.com/w3c/web-platform-tests/blob/b0efb74111af13f7abf3b3b1860667f98746b07f/dom/events/EventTarget-constructible.any.js#L27-L61

-Boris

Gijs Kruitbosch

unread,
Nov 20, 2017, 6:28:09 AM11/20/17
to Boris Zbarsky
On 19/11/2017 03:55, Boris Zbarsky wrote:
> Devtools bug: I don't think devtools need to do anything special here.

Devtools' inspector lets you see which DOM nodes have event listeners
attached to them. It would be neat if they could provide the same
support in the debugger for instances of EventTarget (or any "subclasses").

~ Gijs

Boris Zbarsky

unread,
Nov 20, 2017, 12:13:59 PM11/20/17
to
On 11/20/17 6:28 AM, Gijs Kruitbosch wrote:
> Devtools' inspector lets you see which DOM nodes have event listeners
> attached to them. It would be neat if they could provide the same
> support in the debugger for instances of EventTarget (or any "subclasses").

Hmm. So there are at least three possible things you might be asking
for here:

1) In the existing debugger "events" view, include EventTargets other
than windows and nodes.

2) When examining an object that happens to be an EventTarget in the
console, provide some UI to see its event listeners (similar to the "ev"
marker on nodes in the inspector).

3) When examining an object that happens to be an EventTarget in the
debugger (e.g. in the watch expression window? Where else?) provide
some UI to see its event listeners.

Was it one of those? Or something else?

-Boris

Gijs Kruitbosch

unread,
Nov 20, 2017, 12:26:37 PM11/20/17
to
On 20/11/2017 17:13, Boris Zbarsky wrote:
> On 11/20/17 6:28 AM, Gijs Kruitbosch wrote:
>> Devtools' inspector lets you see which DOM nodes have event listeners
>> attached to them. It would be neat if they could provide the same
>> support in the debugger for instances of EventTarget (or any
>> "subclasses").
>
> Hmm.  So there are at least three possible things you might be asking
> for here:
>
> 1)  In the existing debugger "events" view, include EventTargets other
> than windows and nodes.

I don't see the "events" view in the current debugger in 57/58/59
anymore, but perhaps I'm not looking in the right place. If it still
exists, yes, that would be nice.

> 2)  When examining an object that happens to be an EventTarget in the
> console, provide some UI to see its event listeners (similar to the "ev"
> marker on nodes in the inspector).
>
> 3)  When examining an object that happens to be an EventTarget in the
> debugger (e.g. in the watch expression window?  Where else?) provide
> some UI to see its event listeners.
>
> Was it one of those?  Or something else?

I was thinking more of these, ie the watch expressions and/or variables
(locals/scopes) view and the console.

~ Gijs

Boris Zbarsky

unread,
Nov 20, 2017, 12:38:52 PM11/20/17
to
On 11/20/17 12:26 PM, Gijs Kruitbosch wrote:
> I don't see the "events" view in the current debugger in 57/58/59
> anymore, but perhaps I'm not looking in the right place.

Oh, right, it's not implemented in the new debugger yet... I keep
forgetting that I have the new debugger disabled for precisely that
reason. :(

I can't find any existing open issues on this, though I was sure there
were some. Ah, well, filed
https://github.com/devtools-html/debugger.html/issues/4750

> I was thinking more of these, ie the watch expressions and/or variables
> (locals/scopes) view and the console.

Filed https://github.com/devtools-html/debugger.html/issues/4751 for the
former and https://bugzilla.mozilla.org/show_bug.cgi?id=1419089 for the
latter.

This would be useful even without these "custom" EventTargets, because
it could be used for XHR objects and whatnot...

-Boris
0 new messages