Re: [whatwg/dom] Add window.event, event.srcElement, event.returnValue as a legacy compat requirements (#407)

annevk commented on this pull request.



> @@ -499,6 +505,16 @@ list of tuples, each of which consists of an <b>item</b> (an {{EventTarget}} obj
 object). A tuple is formatted as (<b>item</b>, <b>target</b>, <b>relatedTarget</b>). A <a
 for=Event>path</a> is initially the empty list.</p>
 
+For web compatibility, the <a>current global object</a> has an
+<dfn attribute for=Window><code>event</code></dfn> attribute that always returns the <a>current event</a>
+during <a>dispatch</a>, and is otherwise undefined. The <dfn type=dfn id=concept-current-event>current event</dfn>
+is the <var>event</var> passed to <a>inner invoke</a>. If <var>event</var>'s {{Event/target}} <a for=tree>root</a>
+is a <a for=/>shadow root</a>, the <a>current event</a> is undefined.
+
+<p class="note no-backref">Authors <span class=allow-2119>should</span> explicitly pass in the

Make this "Developers are strongly encouraged" instead of using "authors" and "should".

> @@ -499,6 +505,16 @@ list of tuples, each of which consists of an <b>item</b> (an {{EventTarget}} obj
 object). A tuple is formatted as (<b>item</b>, <b>target</b>, <b>relatedTarget</b>). A <a
 for=Event>path</a> is initially the empty list.</p>
 
+For web compatibility, the <a>current global object</a> has an
+<dfn attribute for=Window><code>event</code></dfn> attribute that always returns the <a>current event</a>
+during <a>dispatch</a>, and is otherwise undefined. The <dfn type=dfn id=concept-current-event>current event</dfn>
+is the <var>event</var> passed to <a>inner invoke</a>. If <var>event</var>'s {{Event/target}} <a for=tree>root</a>
+is a <a for=/>shadow root</a>, the <a>current event</a> is undefined.

This will need to become an imperative definition where we manipulate the internal slot that the attribute reflects from the dispatch algorithm. Declarative definitions often lead to subtle edge cases becoming undefined over time.

> @@ -587,7 +603,8 @@ return the value it was initialized to. When an
 <a>event</a> is created the attribute must be
 initialized to the empty string.
 
-The <dfn attribute for=Event><code>target</code></dfn> and
+The <dfn attribute for=Event><code>target</code></dfn>,
+<dfn attribute for=Event><code>srcElement</code></dfn> and

Oxford comma.

> @@ -731,7 +755,7 @@ To <dfn export for=Event id=concept-event-initialize>initialize</dfn> an
  <a>canceled flag</a>.
  <li>Set the {{Event/isTrusted}} attribute
  to false.
- <li>Set the {{Event/target}} attribute to
+ <li>Set the {{Event/target}} and {{Event/srcElement}} attributes to

An alternative might be that we actually define Event's "target" as a concept and set that here and than have the target and srcElement attributes reflect that.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/407#pullrequestreview-74036566

Received on Friday, 3 November 2017 10:24:06 UTC