[html5] r6654 - [e] (0) Tidy up how event handlers are defined to line up better with WebIDL and [...]

whatwg at whatwg.org whatwg at whatwg.org
Fri Oct 7 15:28:31 PDT 2011


Author: ianh
Date: 2011-10-07 15:28:29 -0700 (Fri, 07 Oct 2011)
New Revision: 6654

Modified:
   complete.html
   index
   source
Log:
[e] (0) Tidy up how event handlers are defined to line up better with WebIDL and DOM Core

Modified: complete.html
===================================================================
--- complete.html	2011-10-07 21:58:30 UTC (rev 6653)
+++ complete.html	2011-10-07 22:28:29 UTC (rev 6654)
@@ -69285,13 +69285,14 @@
   list of <a href=#concept-event-listener title=concept-event-listener>event listeners</a>
   associated with <var title="">T</var> with <i>type</i> set to the
   <dfn id=event-handler-event-type>event handler event type</dfn> corresponding to <var title="">H</var>, <i>capture</i> set to false, and <i>listener</i>
-  set to be an anonymous function that does nothing when the event
-  handler's value is not a <code><a href=#function>Function</a></code> object and <a href=#concept-function-invoke title=concept-Function-invoke>invokes the <code>Function</code>
-  object</a> associated with the <a href=#event-handlers title="event handlers">event
-  handler</a> otherwise. <a href=#refsDOMCORE>[DOMCORE]</a></p>
+  set to <a href=#the-event-handler-processing-algorithm>the event handler processing algorithm</a> defined
+  below. <a href=#refsDOMCORE>[DOMCORE]</a></p>
 
   <p class=note>The <i>listener</i> is emphatically <em>not</em> the
-  <a href=#event-handlers title="event handlers">event handler</a> itself.</p>
+  <a href=#event-handlers title="event handlers">event handler</a> itself. Every
+  event handler ends up registering the same <i>listener</i>, the
+  algorithm defined below, which takes care of invoking the right
+  callback, and processing the callback's return value.</p>
 
   <p class=note>This only happens the first time the <a href=#event-handlers title="event handlers">event handler</a>'s value is set. Since
   listeners are called in the order they were registered, the order of
@@ -69331,36 +69332,53 @@
   not influence whether an <a href=#event-handlers title="event handlers">event
   handler</a> is triggered or not.</p>
 
-  <p>When an <a href=#event-handlers title="event handlers">event handler</a>'s
-  <code><a href=#function>Function</a></code> object is <dfn id=concept-function-invoke title=concept-Function-invoke>invoked</dfn>, its <code title=dom-function-call><a href=#dom-function-call>call()</a></code> callback must be invoked
-  with one argument, set to the <code><a href=#event>Event</a></code> object of the event
-  in question.</p>
+  <p>The <dfn id=the-event-handler-processing-algorithm>the event handler processing algorithm</dfn> for an
+  <a href=#event-handlers title="event handlers">event handler</a> <var title="">H</var> and an <code><a href=#event>Event</a></code> object <var title="">E</var> is as follows:</p>
 
-  <p>The handler's return value must then be processed as follows:</p>
+  <ol><li><p>If <var title="">H</var>'s value is null, then abort these
+   steps.</li>
 
-  <dl class=switch><dt>If the event type is <code class=event-mouseover>mouseover</code></dt>
+   <li><p>Let <var title="">callback</var> be <var title="">H</var>'s
+   value, the <code><a href=#function>Function</a></code> object that the <a href=#event-handlers title="event
+   handlers">event handler</a> was last set to.</li>
 
-   <dd><p>If the return value is a boolean with the value true, then
-   the event must be canceled.</dd>
+   <li><p>Invoke <var title="">callback</var>'s <code title=dom-function-call><a href=#dom-function-call>call()</a></code> operation with one
+   argument, the value of which is the <code><a href=#event>Event</a></code> object <var title="">E</var>, with the <i title=dfn-callback-this-value>callback this value</i> set to the
+   <var title="">E</var>'s <code title=dom-Event-currentTarget>currentTarget</code>. Let the
+   return value be <var title="">return value</var>. <a href=#refsWEBIDL>[WEBIDL]</a></p>
 
-   <dt>If the event object is a <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> object</dt>
+   <li>
 
-   <dd><p>If the return value is a string, and the event object's
-   <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
-   attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
-   attribute's value to the return value.</dd>
+   <li>
 
-   <dt>Otherwise</dt>
+    <p>Process <var title="">return value</var> as follows:</p>
 
-   <dd><p>If the return value is a boolean with the value false, then
-   the event must be canceled.</dd>
+    <dl class=switch><dt>If the event type is <code class=event-mouseover>mouseover</code></dt>
 
-  </dl></div>
+     <dd><p>If <var title="">return value</var> is a boolean with the
+     value true, then cancel the event.</dd>
 
-  <!-- IE actually uncancels the event if the function returns true -->
+     <dt>If the <code><a href=#event>Event</a></code> object <var title="">E</var> is a
+     <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> object</dt>
 
+     <dd><p>If <var title="">return value</var> is a string, and the
+     <code><a href=#event>Event</a></code> object <var title="">E</var>'s <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
+     attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
+     attribute's value to <var title="">return value</var>.</dd>
+
+     <dt>Otherwise</dt>
+
+     <dd><p>If <var title="">return value</var> is a boolean with the
+     value false, then cancel the event.</dd>
+
+     <!-- IE actually uncancels the event if the function returns true -->
+
+    </dl></li>
+
+  </ol></div>
+
   <hr><p>The <code><a href=#function>Function</a></code> interface represents a function in the
-  scripting language being used. It is represented in IDL as
+  scripting language being used. It is represented in Web IDL as
   follows:</p>
 
   <pre class=idl>[Callback=FunctionOnly, NoInterfaceObject]
@@ -69374,11 +69392,6 @@
   <p class=note>In JavaScript, any <code title="">Function</code>
   object implements this interface.</p>
 
-  <p>If the <code><a href=#function>Function</a></code> object is a JavaScript <code title="">Function</code>, then when it is invoked by the user agent,
-  the user agent must set the <var title="">thisArg</var> (as defined
-  by ECMAScript edition 5 section 10.4.3 Entering Function Code) to
-  the <a href=#event-handlers title="event handlers">event handler</a>'s object. <a href=#refsECMA262>[ECMA262]</a></p>
-
   <div class=example>
 
    <p>For example, the following document fragment:</p>
@@ -69391,11 +69404,13 @@
 
   </div>
 
-  <p>The return value of the function affects whether the event is
-  canceled or not: <span class=impl>as described above,</span> if
-  the return value is false, the event is canceled (except for <code class=event-mouseover>mouseover</code> events, where the return
-  value has to be true to cancel the event). With <code title=event-beforeunload>beforeunload</code> events, the value is
-  instead used to determine the message to show the user.</p>
+  <p class=note>The return value of the function affects whether the
+  event is canceled or not: <span class=impl>as described
+  above,</span> if the return value is false, the event is canceled
+  (except for <code class=event-mouseover>mouseover</code> events,
+  where the return value has to be true to cancel the event). With
+  <code title=event-beforeunload>beforeunload</code> events, the
+  value is instead used to determine the message to show the user.</p>
 
 
   <h5 id=event-handlers-on-elements,-document-objects,-and-window-objects><span class=secno>7.1.6.2 </span>Event handlers on elements, <code><a href=#document>Document</a></code> objects, and <code><a href=#window>Window</a></code> objects</h5>

Modified: index
===================================================================
--- index	2011-10-07 21:58:30 UTC (rev 6653)
+++ index	2011-10-07 22:28:29 UTC (rev 6654)
@@ -69285,13 +69285,14 @@
   list of <a href=#concept-event-listener title=concept-event-listener>event listeners</a>
   associated with <var title="">T</var> with <i>type</i> set to the
   <dfn id=event-handler-event-type>event handler event type</dfn> corresponding to <var title="">H</var>, <i>capture</i> set to false, and <i>listener</i>
-  set to be an anonymous function that does nothing when the event
-  handler's value is not a <code><a href=#function>Function</a></code> object and <a href=#concept-function-invoke title=concept-Function-invoke>invokes the <code>Function</code>
-  object</a> associated with the <a href=#event-handlers title="event handlers">event
-  handler</a> otherwise. <a href=#refsDOMCORE>[DOMCORE]</a></p>
+  set to <a href=#the-event-handler-processing-algorithm>the event handler processing algorithm</a> defined
+  below. <a href=#refsDOMCORE>[DOMCORE]</a></p>
 
   <p class=note>The <i>listener</i> is emphatically <em>not</em> the
-  <a href=#event-handlers title="event handlers">event handler</a> itself.</p>
+  <a href=#event-handlers title="event handlers">event handler</a> itself. Every
+  event handler ends up registering the same <i>listener</i>, the
+  algorithm defined below, which takes care of invoking the right
+  callback, and processing the callback's return value.</p>
 
   <p class=note>This only happens the first time the <a href=#event-handlers title="event handlers">event handler</a>'s value is set. Since
   listeners are called in the order they were registered, the order of
@@ -69331,36 +69332,53 @@
   not influence whether an <a href=#event-handlers title="event handlers">event
   handler</a> is triggered or not.</p>
 
-  <p>When an <a href=#event-handlers title="event handlers">event handler</a>'s
-  <code><a href=#function>Function</a></code> object is <dfn id=concept-function-invoke title=concept-Function-invoke>invoked</dfn>, its <code title=dom-function-call><a href=#dom-function-call>call()</a></code> callback must be invoked
-  with one argument, set to the <code><a href=#event>Event</a></code> object of the event
-  in question.</p>
+  <p>The <dfn id=the-event-handler-processing-algorithm>the event handler processing algorithm</dfn> for an
+  <a href=#event-handlers title="event handlers">event handler</a> <var title="">H</var> and an <code><a href=#event>Event</a></code> object <var title="">E</var> is as follows:</p>
 
-  <p>The handler's return value must then be processed as follows:</p>
+  <ol><li><p>If <var title="">H</var>'s value is null, then abort these
+   steps.</li>
 
-  <dl class=switch><dt>If the event type is <code class=event-mouseover>mouseover</code></dt>
+   <li><p>Let <var title="">callback</var> be <var title="">H</var>'s
+   value, the <code><a href=#function>Function</a></code> object that the <a href=#event-handlers title="event
+   handlers">event handler</a> was last set to.</li>
 
-   <dd><p>If the return value is a boolean with the value true, then
-   the event must be canceled.</dd>
+   <li><p>Invoke <var title="">callback</var>'s <code title=dom-function-call><a href=#dom-function-call>call()</a></code> operation with one
+   argument, the value of which is the <code><a href=#event>Event</a></code> object <var title="">E</var>, with the <i title=dfn-callback-this-value>callback this value</i> set to the
+   <var title="">E</var>'s <code title=dom-Event-currentTarget>currentTarget</code>. Let the
+   return value be <var title="">return value</var>. <a href=#refsWEBIDL>[WEBIDL]</a></p>
 
-   <dt>If the event object is a <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> object</dt>
+   <li>
 
-   <dd><p>If the return value is a string, and the event object's
-   <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
-   attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
-   attribute's value to the return value.</dd>
+   <li>
 
-   <dt>Otherwise</dt>
+    <p>Process <var title="">return value</var> as follows:</p>
 
-   <dd><p>If the return value is a boolean with the value false, then
-   the event must be canceled.</dd>
+    <dl class=switch><dt>If the event type is <code class=event-mouseover>mouseover</code></dt>
 
-  </dl></div>
+     <dd><p>If <var title="">return value</var> is a boolean with the
+     value true, then cancel the event.</dd>
 
-  <!-- IE actually uncancels the event if the function returns true -->
+     <dt>If the <code><a href=#event>Event</a></code> object <var title="">E</var> is a
+     <code><a href=#beforeunloadevent>BeforeUnloadEvent</a></code> object</dt>
 
+     <dd><p>If <var title="">return value</var> is a string, and the
+     <code><a href=#event>Event</a></code> object <var title="">E</var>'s <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
+     attribute's value is the empty string, then set the <code title=dom-BeforeUnloadEvent-returnValue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code>
+     attribute's value to <var title="">return value</var>.</dd>
+
+     <dt>Otherwise</dt>
+
+     <dd><p>If <var title="">return value</var> is a boolean with the
+     value false, then cancel the event.</dd>
+
+     <!-- IE actually uncancels the event if the function returns true -->
+
+    </dl></li>
+
+  </ol></div>
+
   <hr><p>The <code><a href=#function>Function</a></code> interface represents a function in the
-  scripting language being used. It is represented in IDL as
+  scripting language being used. It is represented in Web IDL as
   follows:</p>
 
   <pre class=idl>[Callback=FunctionOnly, NoInterfaceObject]
@@ -69374,11 +69392,6 @@
   <p class=note>In JavaScript, any <code title="">Function</code>
   object implements this interface.</p>
 
-  <p>If the <code><a href=#function>Function</a></code> object is a JavaScript <code title="">Function</code>, then when it is invoked by the user agent,
-  the user agent must set the <var title="">thisArg</var> (as defined
-  by ECMAScript edition 5 section 10.4.3 Entering Function Code) to
-  the <a href=#event-handlers title="event handlers">event handler</a>'s object. <a href=#refsECMA262>[ECMA262]</a></p>
-
   <div class=example>
 
    <p>For example, the following document fragment:</p>
@@ -69391,11 +69404,13 @@
 
   </div>
 
-  <p>The return value of the function affects whether the event is
-  canceled or not: <span class=impl>as described above,</span> if
-  the return value is false, the event is canceled (except for <code class=event-mouseover>mouseover</code> events, where the return
-  value has to be true to cancel the event). With <code title=event-beforeunload>beforeunload</code> events, the value is
-  instead used to determine the message to show the user.</p>
+  <p class=note>The return value of the function affects whether the
+  event is canceled or not: <span class=impl>as described
+  above,</span> if the return value is false, the event is canceled
+  (except for <code class=event-mouseover>mouseover</code> events,
+  where the return value has to be true to cancel the event). With
+  <code title=event-beforeunload>beforeunload</code> events, the
+  value is instead used to determine the message to show the user.</p>
 
 
   <h5 id=event-handlers-on-elements,-document-objects,-and-window-objects><span class=secno>7.1.6.2 </span>Event handlers on elements, <code><a href=#document>Document</a></code> objects, and <code><a href=#window>Window</a></code> objects</h5>

Modified: source
===================================================================
--- source	2011-10-07 21:58:30 UTC (rev 6653)
+++ source	2011-10-07 22:28:29 UTC (rev 6654)
@@ -78818,14 +78818,14 @@
   associated with <var title="">T</var> with <i>type</i> set to the
   <dfn>event handler event type</dfn> corresponding to <var
   title="">H</var>, <i>capture</i> set to false, and <i>listener</i>
-  set to be an anonymous function that does nothing when the event
-  handler's value is not a <code>Function</code> object and <span
-  title="concept-Function-invoke">invokes the <code>Function</code>
-  object</span> associated with the <span title="event handlers">event
-  handler</span> otherwise. <a href="#refsDOMCORE">[DOMCORE]</a></p>
+  set to <span>the event handler processing algorithm</span> defined
+  below. <a href="#refsDOMCORE">[DOMCORE]</a></p>
 
   <p class="note">The <i>listener</i> is emphatically <em>not</em> the
-  <span title="event handlers">event handler</span> itself.</p>
+  <span title="event handlers">event handler</span> itself. Every
+  event handler ends up registering the same <i>listener</i>, the
+  algorithm defined below, which takes care of invoking the right
+  callback, and processing the callback's return value.</p>
 
   <p class="note">This only happens the first time the <span
   title="event handlers">event handler</span>'s value is set. Since
@@ -78868,45 +78868,73 @@
   not influence whether an <span title="event handlers">event
   handler</span> is triggered or not.</p>
 
-  <p>When an <span title="event handlers">event handler</span>'s
-  <code>Function</code> object is <dfn
-  title="concept-Function-invoke">invoked</dfn>, its <code
-  title="dom-function-call">call()</code> callback must be invoked
-  with one argument, set to the <code>Event</code> object of the event
-  in question.</p>
+  <p>The <dfn>the event handler processing algorithm</dfn> for an
+  <span title="event handlers">event handler</span> <var
+  title="">H</var> and an <code>Event</code> object <var
+  title="">E</var> is as follows:</p>
 
-  <p>The handler's return value must then be processed as follows:</p>
+  <ol>
 
-  <dl class="switch">
+   <li><p>If <var title="">H</var>'s value is null, then abort these
+   steps.</p></li>
 
-   <dt>If the event type is <code class="event-mouseover">mouseover</code></dt>
+   <li><p>Let <var title="">callback</var> be <var title="">H</var>'s
+   value, the <code>Function</code> object that the <span title="event
+   handlers">event handler</span> was last set to.</p></li>
 
-   <dd><p>If the return value is a boolean with the value true, then
-   the event must be canceled.</p></dd>
+   <li><p>Invoke <var title="">callback</var>'s <code
+   title="dom-function-call">call()</code> operation with one
+   argument, the value of which is the <code>Event</code> object <var
+   title="">E</var>, with the <i
+   title="dfn-callback-this-value">callback this value</i> set to the
+   <var title="">E</var>'s <code
+   title="dom-Event-currentTarget">currentTarget</code>. Let the
+   return value be <var title="">return value</var>. <a
+   href="#refsWEBIDL">[WEBIDL]</a></p>
 
-   <dt>If the event object is a <code>BeforeUnloadEvent</code> object</dt>
+   <li>
 
-   <dd><p>If the return value is a string, and the event object's
-   <code title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
-   attribute's value is the empty string, then set the <code
-   title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
-   attribute's value to the return value.</p></dd>
+   <li>
 
-   <dt>Otherwise</dt>
+    <p>Process <var title="">return value</var> as follows:</p>
 
-   <dd><p>If the return value is a boolean with the value false, then
-   the event must be canceled.</p></dd>
+    <dl class="switch">
 
-  </dl>
+     <dt>If the event type is <code
+     class="event-mouseover">mouseover</code></dt>
 
+     <dd><p>If <var title="">return value</var> is a boolean with the
+     value true, then cancel the event.</p></dd>
+
+     <dt>If the <code>Event</code> object <var title="">E</var> is a
+     <code>BeforeUnloadEvent</code> object</dt>
+
+     <dd><p>If <var title="">return value</var> is a string, and the
+     <code>Event</code> object <var title="">E</var>'s <code
+     title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
+     attribute's value is the empty string, then set the <code
+     title="dom-BeforeUnloadEvent-returnValue">returnValue</code>
+     attribute's value to <var title="">return value</var>.</p></dd>
+
+     <dt>Otherwise</dt>
+
+     <dd><p>If <var title="">return value</var> is a boolean with the
+     value false, then cancel the event.</p></dd>
+
+     <!-- IE actually uncancels the event if the function returns true -->
+
+    </dl>
+
+   </li>
+
+  </ol>
+
   </div>
 
-  <!-- IE actually uncancels the event if the function returns true -->
-
   <hr>
 
   <p>The <code>Function</code> interface represents a function in the
-  scripting language being used. It is represented in IDL as
+  scripting language being used. It is represented in Web IDL as
   follows:</p>
 
   <pre class="idl">[Callback=FunctionOnly, NoInterfaceObject]
@@ -78920,13 +78948,6 @@
   <p class="note">In JavaScript, any <code title="">Function</code>
   object implements this interface.</p>
 
-  <p>If the <code>Function</code> object is a JavaScript <code
-  title="">Function</code>, then when it is invoked by the user agent,
-  the user agent must set the <var title="">thisArg</var> (as defined
-  by ECMAScript edition 5 section 10.4.3 Entering Function Code) to
-  the <span title="event handlers">event handler</span>'s object. <a
-  href="#refsECMA262">[ECMA262]</a></p>
-
   <div class="example">
 
    <p>For example, the following document fragment:</p>
@@ -78941,13 +78962,13 @@
 
   </div>
 
-  <p>The return value of the function affects whether the event is
-  canceled or not: <span class="impl">as described above,</span> if
-  the return value is false, the event is canceled (except for <code
-  class="event-mouseover">mouseover</code> events, where the return
-  value has to be true to cancel the event). With <code
-  title="event-beforeunload">beforeunload</code> events, the value is
-  instead used to determine the message to show the user.</p>
+  <p class="note">The return value of the function affects whether the
+  event is canceled or not: <span class="impl">as described
+  above,</span> if the return value is false, the event is canceled
+  (except for <code class="event-mouseover">mouseover</code> events,
+  where the return value has to be true to cancel the event). With
+  <code title="event-beforeunload">beforeunload</code> events, the
+  value is instead used to determine the message to show the user.</p>
 
 
   <h5>Event handlers on elements, <code>Document</code> objects, and <code>Window</code> objects</h5>




More information about the Commit-Watchers mailing list