<?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>12949</bug_id>
          
          <creation_ts>2011-06-13 23:25:54 +0000</creation_ts>
          <short_desc>click() shouldn&apos;t have special powers over dispatching click event manually</short_desc>
          <delta_ts>2011-09-21 23:01: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>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</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>ian</cc>
    
    <cc>jan.varga</cc>
    
    <cc>jonas</cc>
    
    <cc>jrossi</cc>
    
    <cc>mike</cc>
    
    <cc>mounir</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>49538</commentid>
    <comment_count>0</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-13 23:25:54 +0000</bug_when>
    <thetext>Right now the spec says that click() may cause the default action
to happen, but dispatching click manually doesn&apos;t have the same
effect.
I don&apos;t understand why. Gecko and webkit (if I read the webkit code correctly),
for example, seem to just dispatch click event when click() is called.
Default handling is bound to the elements in the event target chain through
which the event is dispatched. Default handling happens right after the event
has propagated through the chain.

Gecko has one special case for input.click() but I see that as a bug.

I see click() as a leftover from Netscape2/3/IE3 times, or as a 
helper method to dispatch untrusted click event.

(It is however clear that not all default handling should be
processed when handling untrusted event. Both click() and manual dispatching
do dispatch untrusted events.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49546</commentid>
    <comment_count>1</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-06-14 01:02:35 +0000</bug_when>
    <thetext>It&apos;s IMHO very strange that we take action in response to events being fired for a few events in Gecko.

Almost exclusively it works the other way around, events are fired in response to some action being taken.

Unless the web depends on it, this is something that I really think we should make consistent in Gecko (and webkit).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49576</commentid>
    <comment_count>2</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-14 11:05:09 +0000</bug_when>
    <thetext>Jonas, your comments was a response to
&quot;(It is however clear that not all default handling should be
processed when handling untrusted event. Both click() and manual dispatching
do dispatch untrusted events.)&quot; right?
If so, I&apos;ll file a followup bug about that.

In this bug I&apos;m more worried about the click() handling being
different from dispatching click event manually without no reason.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49608</commentid>
    <comment_count>3</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-06-15 02:53:47 +0000</bug_when>
    <thetext>Ok, so smaug pointed out to me that for calling click() firefox generally doesn&apos;t actually activate most elements, which at least for &lt;a&gt;.click() appears to be the case. (though &lt;input type=file&gt;.click() does bring up a file picker, but I think that&apos;s an exception).

The thing that I care most about is that the spec doesn&apos;t say that dispatching an event using the EventTarget interface should run what is usually that events default action. But if that&apos;s not what the spec says then I&apos;m fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49633</commentid>
    <comment_count>4</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-15 10:13:47 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; (though &lt;input type=file&gt;.click() does bring up a file picker,
&gt; but I think that&apos;s an exception).
And that is a recently added exception, which should be fixed to 
work like other event handling.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49636</commentid>
    <comment_count>5</comment_count>
      <attachid>997</attachid>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-15 13:45:19 +0000</bug_when>
    <thetext>Created attachment 997
testcase

This shows that default handling is done during event dispatch.
The testcase should work on Gecko, Webkit, Opera and IE9 and all
change the state of the checkbox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49638</commentid>
    <comment_count>6</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-15 13:49:04 +0000</bug_when>
    <thetext>So the way activation behavior is defined in HTML is just wrong - 
well at least it doesn&apos;t reflect the reality.
Or I&apos;m reading the spec wrong.
Anyway, click() doesn&apos;t work differently to dispatching click manually.

There can be differences in default handling, but that is a separate thing.

In Gecko, and I think in Webkit too, and based on the testcase also
other browsers there is
1. event target chain creation
2. pre-handle-event phase
3. actual dom event dispatch
4. post-handle-event phase, including default handling</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49694</commentid>
    <comment_count>7</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-06-16 17:12:50 +0000</bug_when>
    <thetext>I really don&apos;t think that dispatching an event manually should trigger default handling. For the vast majority of events that doesn&apos;t make any sense (onload for example) and for many others it doesn&apos;t work (onmousemove doesn&apos;t trigger :hover).

So we should really try to get rid of this broken behavior from gecko. Of course, if that ends up breaking too many sites we&apos;ll have to reevaluate, but we should at least try.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49699</commentid>
    <comment_count>8</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-16 17:41:34 +0000</bug_when>
    <thetext>load event doesn&apos;t have default handling.

I don&apos;t understand why HTML needs to specify something against all the
implementations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49701</commentid>
    <comment_count>9</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-16 17:47:32 +0000</bug_when>
    <thetext>And if we want to change how all the browser work, we certainly should not
change click() handling, but add some new method activate() which would work
the new way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49702</commentid>
    <comment_count>10</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-16 17:48:39 +0000</bug_when>
    <thetext>...though, the change to event handling and not changing click() would
break even more :/

I wish the spec would just specify the reality.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49722</commentid>
    <comment_count>11</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-06-16 18:50:02 +0000</bug_when>
    <thetext>Also, DOM 3 Events, at least the way I read, associate
default actions to events, and the default action may happen when
event is dispatched.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50598</commentid>
    <comment_count>12</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-02 13:54:35 +0000</bug_when>
    <thetext>some info:
http://lists.w3.org/Archives/Public/public-html-diffs/2009Jun/0167.html

see the commit message:
Fold command.click() into the regular HTMLElement.click().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50599</commentid>
    <comment_count>13</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-02 14:02:23 +0000</bug_when>
    <thetext>http://krijnhoetmer.nl/irc-logs/whatwg/20090723

&quot;anyway, the idea was for DOM3Events to define activation behavior and various related thingies, but bjoern never got around to it so now it&apos;s defined in HTML5&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50601</commentid>
    <comment_count>14</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-02 15:13:59 +0000</bug_when>
    <thetext>I think that &quot;Firing a synthetic click event at the element does not cause any of the actions described above to happen.&quot; only applies to the &lt;command&gt; element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50606</commentid>
    <comment_count>15</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-03 09:37:17 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; So the way activation behavior is defined in HTML is just wrong - 
&gt; well at least it doesn&apos;t reflect the reality.
&gt; Or I&apos;m reading the spec wrong.
&gt; Anyway, click() doesn&apos;t work differently to dispatching click manually.
&gt; 
&gt; There can be differences in default handling, but that is a separate thing.
&gt; 
&gt; In Gecko, and I think in Webkit too, and based on the testcase also
&gt; other browsers there is
&gt; 1. event target chain creation
&gt; 2. pre-handle-event phase
&gt; 3. actual dom event dispatch
&gt; 4. post-handle-event phase, including default handling

I think that pre-handle-event phase corresponds to &quot;pre-click activation steps&quot;.
post-handle-event-phase runs &quot;post-click activation steps&quot; or &quot;canceled activation steps&quot; (at least for nsHTMLInputElement)

http://www.w3.org/TR/DOM-Level-3-Events/ - 3.5 Activation triggers and behavior) says it&apos;s up to host language to indicate which elements have activation behavior.

http://www.whatwg.org/specs/web-apps/current-work/ - 4.10.7.1.16 Checkbox state
&quot;If the element is mutable, then: The pre-click activation steps consist of setting the element&apos;s checkedness to its opposite value (i.e. true if it is false, false if it is true), and of setting the element&apos;s indeterminate IDL attribute to false. The canceled activation steps consist of setting the checkedness and the element&apos;s indeterminate IDL attribute back to the values they had before the pre-click activation steps were run. The activation behavior is to fire a simple event that bubbles named change at the element.&quot;

that&apos;s exactly what nsHTMLInputElement does

however, the HTML5 spec adds command definitions and &quot;enhance&quot; element.click() in a way, I found out that there use to be a Command IDL interface:

interface Command {
  readonly attribute DOMString commandType;          
  readonly attribute DOMString id;
  readonly attribute DOMString label;
  readonly attribute DOMString title;
  readonly attribute DOMString icon;
  readonly attribute boolean hidden;
  readonly attribute boolean disabled;              
  readonly attribute boolean checked;              
  void click();
  readonly attribute HTMLCollection triggers;
  readonly attribute Command command;
};

you can find more details in the first (SVN) revision of the spec

at that time only &lt;a&gt;, &lt;button&gt;, &lt;input&gt;, &lt;option&gt; and &lt;command&gt; could define a command and command.click() was defined to trigger the action for the command

however, after some time (several years), accesskey=&quot;&quot; was added as another possibility to define a command
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-May/019579.html
so now any element can define a command and it is quite logical to merge the Command and HTMLElement IDL interface.

so element.click() got these &quot;special&quot; powers ... to trigger the action for the command

Now when I look at the definition of &quot;Action&quot; in http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#concept-command

4.11.5.1 &lt;a href&gt;
 - fire a click event at the element.

4.11.5.2 &lt;button&gt;
 - fire a click event at the element.

4.11.5.3 &lt;input&gt;
 - if the element has a defined activation behavior, is to run synthetic click activation steps on the element. Otherwise, it is just to fire a click event at the element.

4.11.5.4 &lt;option&gt;
 - If the command is of Type &quot;radio&quot; then it must pick the option element. Otherwise, it must toggle the option element.

4.11.5.5 &lt;command&gt;
 - if the element has a defined activation behavior, is to run synthetic click activation steps on the element. Otherwise, it is just to fire a click event at the element.

4.11.5.6 &lt;label accesskey=&quot;&quot;&gt;
 - the same as the respective facets of the element&apos;s labeled control.

4.11.5.7 &lt;legend accesskey=&quot;&quot;&gt;
 - similar to the above

4.11.5.8 any element with accesskey=&quot;&quot;
1. If the element is focusable, run the focusing steps for the element.
2. If the element has a defined activation behavior, run synthetic click activation steps on the element.
3. Otherwise, if the element does not have a defined activation behavior, fire a click event at the element.


so the definition varies a bit, but:
4.11.5.3 is actually just to fire a click event, because pre-click activation steps will be done in the pre-handle-event phase and post-click activation steps / canceled activation steps will be done in the post-handle-event-phase

this should apply even for synthetic click events, the spec says that it shouldn&apos;t apply only for &lt;command&gt; if I&apos;m reading it correctly

4.11.5.4 doesn&apos;t fire a click event, I haven&apos;t figured out why

4.11.5.6 and 4.11.5.7 are special, they just forward click() to other element

4.11.5.8 just adds the focus step


http://www.w3.org/TR/DOM-Level-3-Events/ also specifies Activation event synthesis (3.5.1)

so a synthetic click event is used to trigger activation and HTML5 says activation id done in click() (8.2 Activation)

I hope, it&apos;s now a bit clearer :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50608</commentid>
    <comment_count>16</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-03 10:21:49 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; Ok, so smaug pointed out to me that for calling click() firefox generally
&gt; doesn&apos;t actually activate most elements, which at least for &lt;a&gt;.click() appears
&gt; to be the case. (though &lt;input type=file&gt;.click() does bring up a file picker,
&gt; but I think that&apos;s an exception).
&gt; 
&gt; The thing that I care most about is that the spec doesn&apos;t say that dispatching
&gt; an event using the EventTarget interface should run what is usually that events
&gt; default action. But if that&apos;s not what the spec says then I&apos;m fine.

actually it seems that only &lt;a&gt;.click() doesn&apos;t activate, because the click event is untrusted

http://www.whatwg.org/specs/web-apps/current-work - 4.6.1

now I wonder, how can &lt;a&gt;.click() trigger the command action when it fires untrusted event</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50609</commentid>
    <comment_count>17</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-03 10:28:10 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Jonas, your comments was a response to
&gt; &quot;(It is however clear that not all default handling should be
&gt; processed when handling untrusted event. Both click() and manual dispatching
&gt; do dispatch untrusted events.)&quot; right?
&gt; If so, I&apos;ll file a followup bug about that.
&gt; 
&gt; In this bug I&apos;m more worried about the click() handling being
&gt; different from dispatching click event manually without no reason.

you are right:
http://www.whatwg.org/specs/web-apps/current-work/ - 3.2.5.1.7 Interactive content

&quot;The above doesn&apos;t happen for arbitrary synthetic events dispatched by author script. However, the click() method can be used to make it happen programmatically.&quot;

it&apos;s really confusing</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50610</commentid>
    <comment_count>18</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-03 11:03:29 +0000</bug_when>
    <thetext>(In reply to comment #16)

&gt; actually it seems that only &lt;a&gt;.click() doesn&apos;t activate, because the click
&gt; event is untrusted
&gt; 

well, this was recently fixed in firefox</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50613</commentid>
    <comment_count>19</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-03 11:34:04 +0000</bug_when>
    <thetext>(In reply to comment #17)
&gt; &quot;The above doesn&apos;t happen for arbitrary synthetic events dispatched by author
&gt; script. However, the click() method can be used to make it happen
&gt; programmatically.&quot;
&gt; 

this was first introduced in revision 539
http://html5.org/tools/web-apps-tracker?from=538&amp;to=539
and then changed a bit in revision 541
http://html5.org/tools/web-apps-tracker?from=540&amp;to=541</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50616</commentid>
    <comment_count>20</comment_count>
    <who name="Jan Varga">jan.varga</who>
    <bug_when>2011-07-03 16:40:55 +0000</bug_when>
    <thetext>Ok, so it looks to me that element.click() should fire a click event and provide default action (if the click event was not cancelled). Firing a click event manually should not trigger default action according to the spec.

However, all browsers seem to trigger default handling after manual dispatch as Olli pointed out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50652</commentid>
    <comment_count>21</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-05 09:28:40 +0000</bug_when>
    <thetext>From the logic of dispatching events it does not make sense that the event carries the default action. It should be the context that says to dispatch the event:

if(dispatchEvent(event))
  defaultAction()

It makes way more sense the way HTML defines it now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50653</commentid>
    <comment_count>22</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-07-05 09:33:08 +0000</bug_when>
    <thetext>(In reply to comment #21)
&gt; From the logic of dispatching events it does not make sense that the event
&gt; carries the default action.
Event doesn&apos;t carry the default action.
Default action happens (usually) right after event dispatch, but
before the control is back to the caller.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50655</commentid>
    <comment_count>23</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-05 09:40:25 +0000</bug_when>
    <thetext>If an event does not carry a default action, it does not make sense that just firing an event would trigger a default action. And indeed it does not, given the code snippet I pasted in.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50656</commentid>
    <comment_count>24</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-07-05 09:54:56 +0000</bug_when>
    <thetext>(In reply to comment #23)
&gt; If an event does not carry a default action, it does not make sense that just
&gt; firing an event would trigger a default action.
That still doesn&apos;t explain why?
The default action can be bound to the event target, like it is often
in all the current browser engines.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50659</commentid>
    <comment_count>25</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-05 10:20:15 +0000</bug_when>
    <thetext>That is not how DOM Level 3 Events describes it: http://www.w3.org/TR/2011/WD-DOM-Level-3-Events-20110531/#event-flow-default-cancel

It also does not seem very logical to me. And what implementations do is not exposed as it generally only applies to trusted events so that does not much matter I think.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50660</commentid>
    <comment_count>26</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-07-05 11:01:01 +0000</bug_when>
    <thetext>(In reply to comment #25)
&gt;  And what implementations do is not
&gt; exposed as it generally only applies to trusted events so that does not much
&gt; matter I think.
I&apos;m talking about *untrusted* click event for example.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50661</commentid>
    <comment_count>27</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-05 11:05:07 +0000</bug_when>
    <thetext>click and submit are the only cases I know of and both have been corrected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52679</commentid>
    <comment_count>28</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:03:35 +0000</bug_when>
    <thetext>mass-moved component to LC1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54649</commentid>
    <comment_count>29</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-10 23:28:34 +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: Rejected
Change Description: no spec change
Rationale: 

As others have said, it is the responsibility of the code (UA or script) that dispatches the event to ensure that a default action, if any, is performed. Indeed, the default action could differ based on how is firing the event. For example, one could have an event target to which one dispatches a &quot;foo&quot; event, and if it isn&apos;t canceled, one then pops up an alert... but some other code could instead dispatch a &quot;foo&quot; event, and if it isn&apos;t canceled, adds text to a console.

Historically, browsers have had exceptions to this — different exceptions in each browser. But we&apos;re moving away from this as a rationalisation of the platform.

Now given this model, we do need a mechanism by which one can invoke the default activation behaviour of an element, e.g. to click a button, open an input file dialog, or whatnot. And that&apos;s what click() does.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54685</commentid>
    <comment_count>30</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-11 09:38:59 +0000</bug_when>
    <thetext>Why do you want to move away from something which all the browsers
implement?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55034</commentid>
    <comment_count>31</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-15 05:00:10 +0000</bug_when>
    <thetext>The premise of your question is false.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55050</commentid>
    <comment_count>32</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-15 07:21:20 +0000</bug_when>
    <thetext>How?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55643</commentid>
    <comment_count>33</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-08-23 00:10:54 +0000</bug_when>
    <thetext>We shouldn&apos;t do or don&apos;t do something just because it&apos;s what browsers do. The first question should always be &quot;what is the best API&quot;, *after* that we should ask &quot;would that break the web&quot;. The latter question is *informed* by &quot;what do browsers do&quot;. But just because browsers don&apos;t do something doesn&apos;t mean that it breaks the web.

Did Gecko ever get a bug filed on that dispatching &quot;click&quot; events against a link doesn&apos;t traverse it? Note that this is a different question to if click() traverses the link.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55689</commentid>
    <comment_count>34</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-08-23 12:12:49 +0000</bug_when>
    <thetext>(In reply to comment #33)
&gt; Did Gecko ever get a bug filed on that dispatching &quot;click&quot; events against a
&gt; link doesn&apos;t traverse it?
Yes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56270</commentid>
    <comment_count>35</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-09-04 07:33:02 +0000</bug_when>
    <thetext>Apparently we didn&apos;t get enough bugs filed that we decided to change our implementation. We only changed our implementation in order to make sure that callers of HTMLAnchorElement.click() got the behavior they expected.

I agree with Anne here. Events are a notification mechanism indicating that &quot;something&quot; just happened. They also carry the ability to stop whoever dispatched the event from taking the action they normally would in response to the &quot;something&quot; that just happened.

There are two problems with letting target.dispatchEvent() cause the default action to take place.

1.
We can&apos;t do that for a lot of events with default action since it doesn&apos;t really make sense. For example the default action for the &quot;error&quot; event in indexedDB is to cancel the transaction, but there might not be a transaction running if dispatchEvent is used.

And for the app-cache, the default action is to show various UI, but just calling dispatchEvent doesn&apos;t provide enough information as to what UI would be displayed. Additionally we probably don&apos;t want the page to be able to bring up app-cache UI at will.

And the default action for the &quot;dragstart&quot; event is to initialize a drag&apos;n&apos;drop operation. How would that work if the user isn&apos;t currently performing a drag&apos;n&apos;drop action with the mouse (or touch-screen once we have drag&apos;n&apos;drop there).

2.
If .dispatchEvent causes the default action to run, then that creates a weird secondary meta-API which provides largely duplicated functionality. For example if we let the &quot;error&quot; event in indexedDB abort the current transaction if there is one, then that would be duplicated API since transaction.abort() is already available.

And if we make dispatchEvent of a &quot;keydown&quot; event with .char set to &quot; &quot; execute the default action of dispatching a &quot;click&quot; event, then that means that we have two APIs for dispatching &quot;click&quot; events.


In short, events are fired in response to various things happening. They are not a meta-API for causing things to happen.


I&apos;m aware that we&apos;ve put some of the default action logic in the event-dispatch code in Gecko, but I think that&apos;s the wrong design. Feel free to grab me on irc or elsewhere to discuss what a better design should be.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56273</commentid>
    <comment_count>36</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-09-04 09:57:57 +0000</bug_when>
    <thetext>(In reply to comment #35)
&gt; And if we make dispatchEvent of a &quot;keydown&quot; event with .char set to &quot; &quot; execute
&gt; the default action of dispatching a &quot;click&quot; event, then that means that we have
&gt; two APIs for dispatching &quot;click&quot; events.
dispatching &apos;return&apos; keypress to links does dispatch a click event as
default handling. (&apos; &apos; doesn&apos;t trigger links in Gecko)

&gt; I&apos;m aware that we&apos;ve put some of the default action logic in the event-dispatch
&gt; code in Gecko
Not only in Gecko but in all the browser engines.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56285</commentid>
    <comment_count>37</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2011-09-04 13:48:10 +0000</bug_when>
    <thetext>(In reply to comment #35)
&gt; For example the default action for the &quot;error&quot; event in
&gt; indexedDB is to cancel the transaction, but there might not be a transaction
&gt; running if dispatchEvent is used.
Script initiated events aren&apos;t trusted.
It is easy to spec that  default handling should happen only for trusted events.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56368</commentid>
    <comment_count>38</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-09-06 07:45:56 +0000</bug_when>
    <thetext>That doesn&apos;t reduce inconsistency. It&apos;d still be the case that in some cases dispatchEvent executes the default action, in other cases it wouldn&apos;t.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57129</commentid>
    <comment_count>39</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-09-21 23:01:16 +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: Rejected
Change Description: no spec change
Rationale: I couldn&apos;t put it better than comment 35.

Yes, for individual events, there are particular browsers that get it wrong. But those are bugs, that&apos;s all. A legacy of a poorly-specified age.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>997</attachid>
            <date>2011-06-15 13:45:19 +0000</date>
            <delta_ts>2011-06-15 13:45:19 +0000</delta_ts>
            <desc>testcase</desc>
            <filename>defaulthandling.html</filename>
            <type>text/html</type>
            <size>698</size>
            <attacher name="Olli Pettay">bugs</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgogIDxoZWFkPgogICAgPHRpdGxlPkRlZmF1bHQgaGFuZGxp
bmcgdGVzdDwvdGl0bGU+CiAgICA8c2NyaXB0PgogICAgZnVuY3Rpb24gdGVzdCgpIHsKICAgICAg
dmFyIGUgPSBkb2N1bWVudC5jcmVhdGVFdmVudCgiTW91c2VFdmVudCIpOwogICAgICBlLmluaXRN
b3VzZUV2ZW50KCJjbGljayIsIHRydWUsIHRydWUsIHdpbmRvdywgMCwgMCwgMCwgMCwgMCwgCiAg
ICAgICAgICAgICAgICAgICAgICAgZmFsc2UsIGZhbHNlLCBmYWxzZSwgZmFsc2UsIDAsIG51bGwp
OwogICAgICB2YXIgYyA9IGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJjIik7CiAgICAgIGMuY2hl
Y2tlZCA9IGZhbHNlOwogICAgICB2YXIgY2hlY2tlZCA9IGMuY2hlY2tlZDsKICAgICAgYy5kaXNw
YXRjaEV2ZW50KGUpOwogICAgICBhbGVydCgKICAgICAgICBjaGVja2VkICE9IGMuY2hlY2tlZCA/
CiAgICAgICAgIkRlZmF1bHQgaGFuZGxpbmcgZG9uZSBkdXJpbmcgZGlzcGF0Y2hFdmVudCBjYWxs
IiA6CiAgICAgICAgIkRlZmF1bHQgaGFuZGxpbmcgbm90IGRvbmUgZHVyaW5nIGRpc3BhdGNoRXZl
bnQgY2FsbCIKICAgICAgICApOwogICAgfQogICAgPC9zY3JpcHQ+CiAgPC9oZWFkPgogIDxib2R5
IG9ubG9hZD0idGVzdCgpIj4KICAgIDxpbnB1dCB0eXBlPSJjaGVja2JveCIgaWQ9ImMiPgogIDwv
Ym9keT4KPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>