Skip to content

Commit c4c1c8b

Browse files
authored
Allow constructing and subclassing EventTarget
Closes #441. See also https://www.w3.org/Bugs/Public/show_bug.cgi?id=16487.
1 parent 8f8c1c3 commit c4c1c8b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

dom.bs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ for historical reasons.
876876
<h3 id=interface-eventtarget>Interface {{EventTarget}}</h3>
877877

878878
<pre class=idl>
879-
[Exposed=(Window,Worker)]
879+
[Constructor, Exposed=(Window,Worker)]
880880
interface EventTarget {
881881
void addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options);
882882
void removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options);
@@ -944,6 +944,11 @@ and a <dfn export for=EventTarget>legacy-canceled-activation behavior</dfn> algo
944944
are not to be used for anything else. [[!HTML]]
945945

946946
<dl class=domintro>
947+
<dt><code><var>target</var> = new <a constructor for=EventTarget lt=EventTarget()>EventTarget</a>();</code>
948+
<dd>
949+
Creates a new {{EventTarget}} object, which can be used by developers to <a>dispatch</a> and listen for
950+
<a>events</a>.
951+
947952
<dt><code><var>target</var> . <a method for=EventTarget lt=addEventListener()>addEventListener</a>(<var>type</var>, <var>callback</var> [, <var>options</var>])</code>
948953
<dd>
949954
Appends an <a>event listener</a> for <a>events</a> whose {{Event/type}} attribute value
@@ -1014,6 +1019,17 @@ steps:
10141019
<li><p>Return <var>capture</var>, <var>passive</var>, and <var>once</var>.
10151020
</ol>
10161021

1022+
<p>The <dfn constructor for=EventTarget><code>EventTarget()</code></dfn> constructor, when invoked,
1023+
must return a new {{EventTarget}}.
1024+
1025+
<p class="note">Because of the defaults stated elsewhere, the returned {{EventTarget}}'s
1026+
<a>get the parent</a> algorithm will return null, and it will have no <a>activation behavior</a>,
1027+
<a>legacy-pre-activation behavior</a>, or <a>legacy-canceled-activation behavior</a>.
1028+
1029+
<p class="note">In the future we could allow custom <a>get the parent</a> algorithms. Let us know
1030+
if this would be useful for your programs. For now, all author-created {{EventTarget}}s do not
1031+
participate in a tree structure.</p>
1032+
10171033
<p>The
10181034
<dfn method for=EventTarget><code>addEventListener(<var>type</var>, <var>callback</var>, <var>options</var>)</code></dfn>
10191035
method, when invoked, must run these steps:

0 commit comments

Comments
 (0)