Bug 102069
Summary: | [Shadow DOM]: Event with both target and relatedTarget in the same tree is not stopped at Shadow boundary | ||
---|---|---|---|
Product: | WebKit | Reporter: | Sergey G. Grekhov <sgrekhov> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | hayato, morrita, shinyak, webcomponents-bugzilla |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Bug Depends on: | 102681 | ||
Bug Blocks: | 103230 |
Sergey G. Grekhov
According the Shadow Dom specification "In cases where both relatedTarget and target are part of the same shadow tree, the conforming UAs must stop events at the shadow boundary to avoid the appearance of spurious mouseover and mouseout events firing from the same node.". But in fact such events are not stopped at the Shadow boundary.
Run the following example:
<html>
<head>
<script type="text/javascript">
function test() {
var d = document;
var SR = window.ShadowRoot || window.WebKitShadowRoot;
//Shadow root to play with
var s = new SR(d.querySelector('#host'));
var div1 = d.createElement('div');
div1.setAttribute('style', 'height:40px; width:100%');
div1.setAttribute('id', 'div1');
s.appendChild(div1);
var div2 = d.createElement('div');
div2.setAttribute('style', 'height:40px; width:100%');
div2.setAttribute('id', 'div2');
s.appendChild(div2);
s.addEventListener('mouseover', function(event) {
if (event.relatedTarget.getAttribute('id') != 'div1') {
alert('Wrong relatedTarget');
}
}, false);
d.body.addEventListener('mouseover', function(event) {
alert('Event must be stopped at Shadow boundary!!!!');
}, false);
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("mouseover", true, false, window,
0, 10, 10, 10, 10, false, false, false, false, 0, div1);
div2.dispatchEvent(evt);
}
</script>
</head>
<body onload="test()">
<div id="host">
</div>
</body>
</html>
Event shouldn't buble up to document.body event listener but it bubles.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Hayato Ito
Thank you for the reporting. Let me take a look tomorrow.
Hayato Ito
http://trac.webkit.org/changeset/136818 fixed this. Closing.