Bug 101309

Summary: [Shadow DOM]: Event retargeting doesn’t occur for document nodes distributed to the shadow insertion points
Product: WebKit Reporter: Sergey G. Grekhov <sgrekhov>
Component: DOMAssignee: Hayato Ito <hayato>
Status: RESOLVED WONTFIX    
Severity: Normal CC: dglazkov, hayato, shinyak, webcomponents-bugzilla
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 63606    

Description Sergey G. Grekhov 2012-11-05 23:19:08 PST
Run the following example.

<html>
<head>
<script>
function test() {
       var SR = window.ShadowRoot || window.WebKitShadowRoot;
    var d = document;
    
    var ul = d.querySelector('ul.stories');
    var s = new SR(ul);

    //make shadow subtree
    var div = d.createElement('div');
    div.innerHTML = '<ul id="ip_wrapper"><content select=".shadow"></content></ul>';
    s.appendChild(div);
         
       d.body.addEventListener('click', function (event) {
             alert('event.target.tagName=' + event.target.tagName);
    }, false);
       
    var event = d.createEvent('HTMLEvents');
    event.initEvent ("click", true, false);
    d.querySelector('#li3').dispatchEvent(event);             
}
</script>
</head>
<body onload="test()">
    <ul class='stories'>
        <li id='li1'><a href='#1'>Link1</a></li>
        <li id='li2' title="li2"><a href='#2'>Link 2</a></li>
        <li id='li3' class='shadow'><a href='#3'>Link 3 Shadow</a></li>
        <li id='li4' class='shadow2'><a href='#4'>Link 4 Shadow 2</a></li>
        <li id='li5'><a href='#5'>Link 5</a></li>
        <li id='li6' class='shadow'><a href='#5'>Link 6 Shadow</a></li>
    </ul>
</body>
</html>


This example shows tagName LI. But according http://www.w3.org/TR/shadow-dom/#event-retargeting (see steps 5 and 6 of event retargeting algorithm) UL (a shadow root) should be a relative target.
Comment 1 Hayato Ito 2012-11-05 23:36:52 PST
Let me take a look.
Comment 2 Hayato Ito 2012-11-06 00:07:29 PST
'LI' is correct in this case. That matches my intention and the implementation.

Do you think the spec need to be fixed?
Comment 3 Sergey G. Grekhov 2012-11-06 00:17:02 PST
I believe spec needs to be fixed. I thought that parent calculation algorithm should be invoked in this case. It's not obvious for me that in this case it shouldn't be invoked.
Comment 4 Hayato Ito 2012-11-06 01:04:42 PST
Thank you for the reply.

I think the it might be better to file a bug on the spec if the spec is unclear. So let me close this WebKit's bug.
Please feel free to file a bug on the spec with a reference to this bug.

(In reply to comment #3)
> I believe spec needs to be fixed. I thought that parent calculation algorithm should be invoked in this case. It's not obvious for me that in this case it shouldn't be invoked.
Comment 5 Sergey G. Grekhov 2012-11-06 01:21:34 PST
Bug against specification filled https://www.w3.org/Bugs/Public/show_bug.cgi?id=19875
Comment 6 Dimitri Glazkov (Google) 2012-11-06 09:33:33 PST
Thanks, Sergey. Will look into this.