Skip to content

Commit

Permalink
Allow constructing and subclassing EventTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Jun 21, 2017
1 parent 4512167 commit 05d4c32
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ for historical reasons.
<h3 id=interface-eventtarget>Interface {{EventTarget}}</h3>

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

<dl class=domintro>
<dt><code><var>target</var> = new EventTarget();</code>
<dd>
Creates a new {{EventTarget}} object, which can be used by developers to dispatch and listen for
events.

<dt><code><var>target</var> . <a method for=EventTarget lt=addEventListener()>addEventListener</a>(<var>type</var>, <var>callback</var> [, <var>options</var>])</code>
<dd>
Appends an <a>event listener</a> for <a>events</a> whose {{Event/type}} attribute value
Expand Down Expand Up @@ -1014,6 +1019,19 @@ steps:
<li><p>Return <var>capture</var>, <var>passive</var>, and <var>once</var>.
</ol>

<p>The <dfn constructor for=EventTarget><code>EventTarget()</code></dfn> constructor, when invoked,
must run these steps:

<ol>
<li>Return a new {{EventTarget}} object, using the default <a>get the parent</a> algorithm, and
with no <a>activation behavior</a>, <a>legacy-pre-activation behavior</a>, or
<a>legacy-canceled-activation behavior</a>.
</ol>

<p class="note">In the future we could allow custom <a>get the parent</a> algorithms. Let us know
if this would be useful for your programs. For now, all author-created {{EventTarget}}s do not
participate in a tree structure.</p>

<p>The
<dfn method for=EventTarget><code>addEventListener(<var>type</var>, <var>callback</var>, <var>options</var>)</code></dfn>
method, when invoked, must run these steps:
Expand Down

0 comments on commit 05d4c32

Please sign in to comment.