<?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>25657</bug_id>
          
          <creation_ts>2014-05-11 18:36:00 +0000</creation_ts>
          <short_desc>[D3E] click event after mousedown and mouseup events (more detail)</short_desc>
          <delta_ts>2014-05-28 00:57:05 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - DOM3 Events</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</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="Arkadiusz Michalski (Spirit)">crimsteam</reporter>
          <assigned_to name="Travis Leithead [MSFT]">travil</assigned_to>
          <cc>bugs</cc>
    
    <cc>mike</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>105643</commentid>
    <comment_count>0</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-05-11 18:36:00 +0000</bug_when>
    <thetext>D3E is the only specification where this behavior is described? If yes then definition should be more accurate. Now we have only this:

&quot;Each implementation will determine the appropriate hysteresis tolerance, but in general SHOULD fire click and dblclick events when the event target of the associated mousedown and mouseup events is the same element with no mouseout or mouseleave events intervening, and SHOULD fire click and dblclick events on the nearest common ancestor when the event targets of the associated mousedown and mouseup events are different.&quot;

But ancestor for which target (mousedown, mouseup or both)? When both what if we have mousedown on &lt;body&gt; and mouseup on &lt;html&gt;? What target will be set? Mayebe use term sth like this: nearest common &quot;inclusive ancestor&quot; (http://www.w3.org/TR/dom/#concept-tree-inclusive-ancestor) will be better.

Just only suggest to add more details because now we have different behaviors in browsers:
https://bugzilla.mozilla.org/show_bug.cgi?id=1004895</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105799</commentid>
    <comment_count>1</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-05-13 00:54:13 +0000</bug_when>
    <thetext>Theoretical examples in IE and Chrome (Firefox never generate click event in this cases). 

Case1:
&lt;body&gt;(click target)
 &lt;div&gt;mousedown target&lt;div&gt;
 &lt;p&gt;mouseup target&lt;p&gt;
&lt;/body&gt; 

Case2:
&lt;div&gt;mousedown target (click target)
 &lt;p&gt;mouseup target&lt;p&gt;
&lt;div&gt;

Case3:
&lt;html&gt;mouseup target (click target)
 &lt;body&gt;mousedown target&lt;body&gt;
&lt;/html&gt; 

This browser have strange behaviour when move mouse to adding content (mousedown generate sth and we move mouse to this, especially text node in Chrome) and when mouseup adding sth too, but it looks like a bug, sometimes it&apos;s different in IE and Chrome. 

Small practical test:

&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;

	&lt;style&gt;
		* { outline: none; }
		body &gt; * { outline: none; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
	&lt;/style&gt;

&lt;body&gt;

	&lt;div style=&quot;background-color: #CCC; border: 1px solid #888;&quot; id=&quot;dragel&quot;&gt;
		Some DIV1. Drag me to a below paragraph to receive click event.
	&lt;/div&gt;
	&lt;p&gt;Some paragraph P1 outside DIV1.&lt;/p&gt;

	&lt;div style=&quot;background-color: #FFF; border: 1px solid #888;&quot; &gt;Another DIV2. Drag me to a below paragraph to receive click event.
	&lt;p&gt;Another paragraph P2 inside DIV2. &lt;/p&gt;
	&lt;/div&gt;

	&lt;div id=&quot;output&quot; style=&quot;border: 1px solid #888;&quot;&gt;&lt;/div&gt;

	&lt;script&gt;
		var elem = document.getElementById(&quot;output&quot;);

		window.addEventListener(&quot;mousedown&quot;, function(e){
			elem.innerHTML += &quot;e.type: &quot; + e.type
			+ &quot;&lt;br&gt;&quot; + &quot;e.target: &quot; + e.target + &quot;&lt;br&gt;&lt;br&gt;&quot;;
		});

		window.addEventListener(&quot;mouseup&quot;, function(e){
			elem.innerHTML += &quot;e.type: &quot; + e.type
			+ &quot;&lt;br&gt;&quot; + &quot;e.target: &quot; + e.target + &quot;&lt;br&gt;&lt;br&gt;&quot;;
		});

		window.addEventListener(&quot;click&quot;, function(e){
			elem.innerHTML += &quot;e.type: &quot; + e.type
			+ &quot;&lt;br&gt;&quot; + &quot;e.target: &quot; + e.target + &quot;&lt;br&gt;&lt;br&gt;&quot;;
		});

	&lt;/script&gt;

&lt;/body&gt;

&lt;/html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105827</commentid>
    <comment_count>2</comment_count>
    <who name="Olli Pettay">bugs</who>
    <bug_when>2014-05-13 11:07:50 +0000</bug_when>
    <thetext>At some point, IIRC, D3E said that click should be dispatched only if
mousedown and up have the same target, and didn&apos;t have anything about
nearest common ancestor. When was that &quot;nearest common ancestor&quot; part added?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105900</commentid>
    <comment_count>3</comment_count>
    <who name="Arkadiusz Michalski (Spirit)">crimsteam</who>
    <bug_when>2014-05-13 19:24:10 +0000</bug_when>
    <thetext>W3C Working Draft 31 May 2011
http://www.w3.org/TR/2011/WD-DOM-Level-3-Events-20110531/

&quot;Note that the lag time, degree, distance, and number of mousemove events allowed between the mousedown and mouseup events while still firing a click or dblclick event must be implementation-, device-, and platform-specific. Each implementation should determine the appropriate hysteresis tolerance, but in general should fire click and dblclick events when the event target of the associated mousedown and mouseup events is the same element with no mouseout or mouseleave events intervening, and should not fire click and dblclick events when the event target of the associated mousedown and mouseup events is different.&quot;

Next version change this:

W3C Working Draft 14 June 2012
http://www.w3.org/TR/2012/WD-DOM-Level-3-Events-20120614/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106749</commentid>
    <comment_count>4</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-05-23 23:20:00 +0000</bug_when>
    <thetext>Yes, thanks for this example file. It appears that the WebKit/Trident behavior finds the nearest inclusive ancestor (i.e., if the event targets are the same, that&apos;s the click target; if one target includes the other, that is the click target. If neither include each other, then it&apos;s the nearest common ancestor.

I can make this spec update.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106872</commentid>
    <comment_count>5</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2014-05-28 00:57:05 +0000</bug_when>
    <thetext>I clarified this text, and added an example as well.

https://dvcs.w3.org/hg/dom3events/rev/01ded2704b4b</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>