<?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>21404</bug_id>
          
          <creation_ts>2013-03-26 18:56:14 +0000</creation_ts>
          <short_desc>[Shadow]: 5.5 Event Dispatch references incorrect steps of event dispatching algorithm</short_desc>
          <delta_ts>2013-05-07 22:11:32 +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 - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</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>
          
          <blocked>18428</blocked>
    
    <blocked>21499</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Daniel Freedman">dfreedm</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>bugs</cc>
    
    <cc>hayato</cc>
    
    <cc>mrbkap</cc>
    
    <cc>sorvell</cc>
    
    <cc>wchen</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>85032</commentid>
    <comment_count>0</comment_count>
    <who name="Daniel Freedman">dfreedm</who>
    <bug_when>2013-03-26 18:56:14 +0000</bug_when>
    <thetext>In section 5.5, where the event dispatching algorithm detailed in http://www.w3.org/TR/domcore/#dispatching-events is referenced, the capturing phase should reference step 6 of the event dispatching algorithm, and the bubbling phase should reference step 9.

As currently written, bubbling events processing through a Shadow Root would be processed in a capture order.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85160</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-03-29 20:14:11 +0000</bug_when>
    <thetext>Olli, wanted to check with you on this. It makes good sense to me. Here&apos;s a really good example that Daniel built: http://jsfiddle.net/dfreedm/EMgtb/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85194</commentid>
    <comment_count>2</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-04-01 01:37:05 +0000</bug_when>
    <thetext>Maybe we should revert this change in WebKit side:

https://bugs.webkit.org/show_bug.cgi?id=112214

I think the original behavior in WebKit is what we want.
What we have to do is to update the spec so that the spec matches the WebKit&apos;s original behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85195</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-04-01 02:35:50 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Maybe we should revert this change in WebKit side:
&gt; 
&gt; https://bugs.webkit.org/show_bug.cgi?id=112214

Okay.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85196</commentid>
    <comment_count>4</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-04-01 02:37:02 +0000</bug_when>
    <thetext>To continue further, let me confirm &apos;the desired behavior&apos; at first.

Given the event path, from Node A (top-most) to Node G (target, inner-most), where C and D are shadow hosts and G is the target, 

an event dispatching order in the current WebKit implementaion is:
(T: AT_TARGET, C: CAPTURING, B: BUBBLING)


For bubbling events:

  A          1 (C)  11 (B)
  B          2 (C)  10 (B)
  C (SH)     3 (T) 
  D          4 (C)   9 (B)
  E (SH)     5 (T)
  F          6 (C)   8 (B)
  G (Target) 7 (T)  


For non-bubbling events:

  A          1 (C)
  B          2 (C)
  C (SH)     3 (T) 
  D          4 (C)
  E (SH)     5 (T)
  F          6 (C)
  G (Target) 7 (T)  


Are we changing this behavior?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85197</commentid>
    <comment_count>5</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-04-01 02:42:01 +0000</bug_when>
    <thetext>Let me ignore my comment #2. Could you see comment #4?

(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; Maybe we should revert this change in WebKit side:
&gt; &gt; 
&gt; &gt; https://bugs.webkit.org/show_bug.cgi?id=112214
&gt; 
&gt; Okay.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85199</commentid>
    <comment_count>6</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-04-01 03:08:19 +0000</bug_when>
    <thetext>(In reply to comment #5)

I think what Daniel wants is:

  A          1 (C)  
  B          2 (C)
  C (SH)            7 (T)
  D          3 (C)
  E (SH)            6 (T)
  F          4 (C) 
  G (Target)        5 (T)

Effectively, with Shadow DOM, AT_TARGET phase:
1) mimics bubbling if event is non-bubbling, or
2) is combined with bubbling otherwise.

Does this make any sense? Does this seem like a good idea? :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85200</commentid>
    <comment_count>7</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-04-01 03:14:13 +0000</bug_when>
    <thetext>I don&apos;t have a strong opinion to either idea.

For me, the original one looks natural one.
I&apos;d like to know the reason and use cases for changing the behavior.


(In reply to comment #6)
&gt; (In reply to comment #5)
&gt; 
&gt; I think what Daniel wants is:
&gt; 
&gt;   A          1 (C)  
&gt;   B          2 (C)
&gt;   C (SH)            7 (T)
&gt;   D          3 (C)
&gt;   E (SH)            6 (T)
&gt;   F          4 (C) 
&gt;   G (Target)        5 (T)
&gt; 
&gt; Effectively, with Shadow DOM, AT_TARGET phase:
&gt; 1) mimics bubbling if event is non-bubbling, or
&gt; 2) is combined with bubbling otherwise.
&gt; 
&gt; Does this make any sense? Does this seem like a good idea? :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85201</commentid>
    <comment_count>8</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-04-01 03:25:30 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; Effectively, with Shadow DOM, AT_TARGET phase:
&gt; 1) mimics bubbling if event is non-bubbling, or
&gt; 2) is combined with bubbling otherwise.
&gt; 
&gt; Does this make any sense? Does this seem like a good idea? :)

I guess that since element.addEventListener&apos;s third parameter, useCapture, is &apos;false&apos; in default, people is likely to have a mental model of &apos;event listernes are called from inner to outer&apos;.
That might support the idea of &apos;minicing bubbling events&apos; for AT_TARGET phase.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85202</commentid>
    <comment_count>9</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-04-01 03:33:15 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; I guess that since element.addEventListener&apos;s third parameter, useCapture,
&gt; is &apos;false&apos; in default, people is likely to have a mental model of &apos;event
&gt; listernes are called from inner to outer&apos;.
&gt; That might support the idea of &apos;minicing bubbling events&apos; for AT_TARGET
&gt; phase.

Right. Most of the time this parameter is false (very few use capture), so the order of events looks whacky: first listener is fired on the host that&apos;s farthest from the target.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85204</commentid>
    <comment_count>10</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-04-01 03:44:35 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; (In reply to comment #8)
&gt; &gt; I guess that since element.addEventListener&apos;s third parameter, useCapture,
&gt; &gt; is &apos;false&apos; in default, people is likely to have a mental model of &apos;event
&gt; &gt; listernes are called from inner to outer&apos;.
&gt; &gt; That might support the idea of &apos;minicing bubbling events&apos; for AT_TARGET
&gt; &gt; phase.
&gt; 
&gt; Right. Most of the time this parameter is false (very few use capture), so
&gt; the order of events looks whacky: first listener is fired on the host that&apos;s
&gt; farthest from the target.

Okay. Agreed. Let&apos;s change the order.
For the record, the new order should be:

For bubbling events:

  A          1 (C)  11 (B)
  B          2 (C)  10 (B)
  C (SH)             9 (T) 
  D          3 (C)   8 (B)
  E (SH)             7 (T)
  F          4 (C)   6 (B)
  G (Target)         5 (T)  


For non-bubbling events:

  A          1 (C)
  B          2 (C)
  C (SH)            7 (T) 
  D          3 (C)
  E (SH)            6 (T)
  F          4 (C)
  G (Target)        5 (T)  

Does this sound good?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85234</commentid>
    <comment_count>11</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-04-01 04:09:22 +0000</bug_when>
    <thetext>I have to address one more issue:
  How to handle event.cancelBubble in the new event order?

For example, if an event lister on Node E sets event.cancelBubble to true on #7, what should be done for (#8 - #11)?

My idea is:
  - Event listeners on #9 should be called with AT_TARGET phase even though.
  - Event listeners on (#8, #10, #11) should not be called with BUBBLING phase.

&gt; For bubbling events:
&gt; 
&gt;   A          1 (C)  11 (B)
&gt;   B          2 (C)  10 (B)
&gt;   C (SH)             9 (T) 
&gt;   D          3 (C)   8 (B)
&gt;   E (SH)             7 (T)
&gt;   F          4 (C)   6 (B)
&gt;   G (Target)         5 (T)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85239</commentid>
    <comment_count>12</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2013-04-01 06:19:05 +0000</bug_when>
    <thetext>For reference, I&apos;ve uploaded a patch in implementation side:
https://bugs.webkit.org/show_bug.cgi?id=113676</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85257</commentid>
    <comment_count>13</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-04-01 15:51:32 +0000</bug_when>
    <thetext>(In reply to comment #11)
&gt; I have to address one more issue:
&gt;   How to handle event.cancelBubble in the new event order?
&gt; 
&gt; For example, if an event lister on Node E sets event.cancelBubble to true on
&gt; #7, what should be done for (#8 - #11)?
&gt; 
&gt; My idea is:
&gt;   - Event listeners on #9 should be called with AT_TARGET phase even though.
&gt;   - Event listeners on (#8, #10, #11) should not be called with BUBBLING
&gt; phase.

I think this is reasonable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87384</commentid>
    <comment_count>14</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-05-07 22:11:32 +0000</bug_when>
    <thetext>https://dvcs.w3.org/hg/webcomponents/rev/1150e6c009d3 Please let me know if I messed things up.

Also, adding William+Blake to keep such changes on their radars.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>