<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>13684</bug_id>
          
          <creation_ts>2011-08-05 10:10:46 +0000</creation_ts>
          <short_desc>Event handler attributes should reregister each time they are changed (?)</short_desc>
          <delta_ts>2011-10-07 21:45:16 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Olli Pettay">bugs</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>contributor</cc>
    
    <cc>ian</cc>
    
    <cc>jrossi</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>54225</commentid>
    <comment_count>0</comment_count>
      <attachid>1021</attachid>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-05 10:10:46 +0000</bug_when>
    <thetext>Created attachment 1021
testcase

&quot; Event handlers therefore always run before event listeners attached using addEventListener()&quot; is wrong.
It is not what browsers (tested F, C, O) do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54227</commentid>
    <comment_count>1</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-05 10:15:18 +0000</bug_when>
    <thetext>*** Bug 13683 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54296</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-06 06:10:30 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Did Not Understand Request
Change Description: no spec change
Rationale: Removing the note is pointless, it&apos;s not normative.

If you want the normative requirements changed, that&apos;s a different matter. What would you like the behaviour to be?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54314</commentid>
    <comment_count>3</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-06 09:50:38 +0000</bug_when>
    <thetext>Event listeners are called in the order they are added to the event target.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54315</commentid>
    <comment_count>4</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-06 09:51:30 +0000</bug_when>
    <thetext>I couldn&apos;t figure out what in the spec leads to &quot;therefore always&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54347</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-08-07 02:19:40 +0000</bug_when>
    <thetext>&gt; I couldn&apos;t figure out what in the spec leads to &quot;therefore always&quot;.

This bit:

  All event handlers on an object, whether an element or some other object, and
  whether set to null or to a Function object, must be registered as event
  listeners on the object when it is created

which means ipso facto that they&apos;re registered before any other event listeners (since those can&apos;t be registered before the object is created).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54351</commentid>
    <comment_count>6</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-07 08:08:09 +0000</bug_when>
    <thetext>Oh, I read that so that if elements have onfoo content attributes, they must be
registered as event listeners when element is basically parsed/created.
But ok, I misread that part.
But anyway, that is buggy, not something browser do, and there is no
need to special case onfoo listeners.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54352</commentid>
    <comment_count>7</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-07 08:10:36 +0000</bug_when>
    <thetext>And also, onfoo listeners have been discussed in WebApps WG, and
decided that they are no special, which is why D3E doesn&apos;t even try to
define them.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54414</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-08 21:56:10 +0000</bug_when>
    <thetext>Will examine further.

Things to test:
 Order of handlers in  addEventListener(), set onhandler, addEventListener()
 Order of handlers in  set onhandler, addEventListener(), set onhandler
 Whether it matters if you&apos;re removing and resetting the attribute, vs changing the attribute.
 Whether the IDL attributes behaves differently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54450</commentid>
    <comment_count>9</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-09 10:38:38 +0000</bug_when>
    <thetext>Gecko seems to keep the onfoo in its place in the event listener list
if one changes (not removes) the onfoo listener.
chrome and opera don&apos;t do that, but apparently remove the old listener
first and then add new.
I&apos;m ok changing Gecko&apos;s behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57072</commentid>
    <comment_count>10</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-09-21 16:47:14 +0000</bug_when>
    <thetext>Pretty sure this needs a hook in DOM4 (DOM Level 3 Events is wrong in that they are nothing special).

http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1143

Using both addEventListener and on* you can register the same listener twice. And you cannot remove the listener added with addEventListener by setting on* to null, etc.

I think event listener needs an additional &quot;event handler flag&quot;.

When you set on* it first removes any event listeners for type=type, listener=listener, event handler flag set, then it appends a new event listener for type=type, listener=listener, with the event handler flag set.

addEventListener meanwhile never has the event handler flag set and when doing equality checking it always checks for unset.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57073</commentid>
    <comment_count>11</comment_count>
    <who name="Jacob Rossi [MSFT]">jrossi</who>
    <bug_when>2011-09-21 16:56:32 +0000</bug_when>
    <thetext>IE matches Firefox in that once on* is set, its position in the ordering is fixed. Changing on* changes the listener but not the order.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57074</commentid>
    <comment_count>12</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-09-21 17:03:04 +0000</bug_when>
    <thetext>If we want that behavior, instead of removing it should then simply change the original entry, if any, and append otherwise, when setting the event handler to a new value.

Hixie, do you agree that http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-event-listener needs a &quot;event handler flag&quot;? (I will also turn capture into a &quot;capture flag&quot; for consistency.)

(I realize we talked about moving event handlers into DOM4, but we should probably wait with that some more.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57078</commentid>
    <comment_count>13</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-09-21 17:28:04 +0000</bug_when>
    <thetext>Setting on* to a function foo does not register a listener for foo. The listener that is actually registered is an anonymous function that then calls foo. So there&apos;s no conflict with aEL() here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57694</commentid>
    <comment_count>14</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-10-03 10:00:14 +0000</bug_when>
    <thetext>Hixie, where does HTML state that? I cannot find such a thing for event handler IDL attributes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57929</commentid>
    <comment_count>15</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-10-07 04:17:05 +0000</bug_when>
    <thetext>Search for the following text (also partly quoted in comment 5 above):

-----8&lt;-----
All event handlers on an object, whether an element or some other object, and whether set to null or to a Function object, must be registered as event listeners on the object when it is created, as if the addEventListener() method on the object&apos;s EventTarget interface had been invoked, with the event type (type argument) equal to the type corresponding to the event handler (the event handler event type), the listener set to be a target and bubbling phase listener (useCapture argument set to false), and the event listener itself (listener argument) set to do nothing while the event handler&apos;s value is not a Function object, and set to invoke the call() callback of the Function object associated with the event handler otherwise.

Note: Event handlers therefore always run before event listeners attached using addEventListener().

Note: The listener argument is emphatically not the event handler itself.
-----8&lt;-----

If I understand correctly, this bug is about changing this so that instead of this happening when the element is created, it happens when the event handler is first set to something other than null.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57930</commentid>
    <comment_count>16</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-10-07 04:18:21 +0000</bug_when>
    <thetext>(Also I&apos;ll clarify the text so that it doesn&apos;t state by confusingly saying that the &quot;event handlers [are] registered as event listeners&quot; since that&apos;s not what the text goes on to actually require.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57966</commentid>
    <comment_count>17</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-10-07 21:21:25 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter&apos;s comments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57967</commentid>
    <comment_count>18</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-10-07 21:45:16 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r6652.
Check-in comment: Define how event handler registration works to be compatible with IE and Firefox.
http://html5.org/tools/web-apps-tracker?from=6651&amp;to=6652</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>1021</attachid>
            <date>2011-08-05 10:10:46 +0000</date>
            <delta_ts>2011-08-05 10:10:46 +0000</delta_ts>
            <desc>testcase</desc>
            <filename>onfootest.html</filename>
            <type>text/html</type>
            <size>646</size>
            <attacher name="Olli Pettay">bugs</attacher>
            
              <data encoding="base64">PGh0bWw+CiAgPGhlYWQ+CiAgICA8c2NyaXB0PgogICAgCiAgICAgIGZ1bmN0aW9uIGNsaWNrKCkg
ewogICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJsIikudGV4dENvbnRlbnQgKz0gImFk
ZEV2ZW50TGlzdGVuZXIgbGlzdGVuZXIgdHJpZ2dlcmVkIFxuIjsgCiAgICAgIH0KICAgICAgCiAg
ICAgIAogICAgICBmdW5jdGlvbiBjbGlja09uRm9vKCkgewogICAgICAgIGRvY3VtZW50LmdldEVs
ZW1lbnRCeUlkKCJsIikudGV4dENvbnRlbnQgKz0gIm9uZm9vIGxpc3RlbmVyIHRyaWdnZXJlZCBc
biI7IAogICAgICB9CiAgICAgIAogICAgICBmdW5jdGlvbiBzZXR1cCgpIHsKICAgICAgICBkb2N1
bWVudC5nZXRFbGVtZW50QnlJZCgiaSIpLmFkZEV2ZW50TGlzdGVuZXIoImNsaWNrIiwgY2xpY2ss
IGZhbHNlKTsKICAgICAgICBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiaSIpLnNldEF0dHJpYnV0
ZSgib25jbGljayIsCiAgICAgICAgICAiY2xpY2tPbkZvbygpIik7CiAgICAgIH0KICAgIDwvc2Ny
aXB0PgogIDwvaGVhZD4KICA8Ym9keSBvbmxvYWQ9InNldHVwKCk7Ij4KICAgIDxpbnB1dCBpZD0i
aSIgdmFsdWU9ImNsaWNrIG1lIiB0eXBlPSJidXR0b24iPgogICAgPHByZSBpZD0ibCI+PC9wcmU+
CiAgPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>