WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
112214
[Shadow Dom]: Non Bubbling events in ShadowDOM dispatch in an incorrect order
https://bugs.webkit.org/show_bug.cgi?id=112214
Summary
[Shadow Dom]: Non Bubbling events in ShadowDOM dispatch in an incorrect order
Daniel Freedman
Reported
2013-03-12 17:29:12 PDT
In the demo shown, a Custom Event is created in the shadow dom that is bubbles: false. The event is dispatched to first child in the shadow, which sets the stop propagation flag. The host event listener fires afterwards. This seems to be incorrect according to step 8 of
http://dom.spec.whatwg.org/#concept-event-dispatch
. If the CustomEvent has bubbles: true, the event listener on host does not fire.
Attachments
Fixed the order.
(20.79 KB, patch)
2013-03-14 21:01 PDT
,
Hayato Ito
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Daniel Freedman
Comment 1
2013-03-13 15:35:21 PDT
After more review, it turns out I was mistaken about stopPropagation. Instead, for non-bubbling events, the listeners for an event at AT_TARGET phase are fired in capture order (top down, DOM order). Given a DOM construction A->{SR}->B, where A and B are DOM nodes with listeners for "focus" and {SR} is a ShadowRoot, if a focus event is dispatched to B, the listeners will fire in order A, B. This seems incorrect.
Hayato Ito
Comment 2
2013-03-13 19:21:12 PDT
Confirmed. The implementation does not seem to follow the change of spec.
https://dvcs.w3.org/hg/webcomponents/rev/f46cfd9b0832
Let me fix that.
Hayato Ito
Comment 3
2013-03-14 21:01:56 PDT
Created
attachment 193228
[details]
Fixed the order.
WebKit Review Bot
Comment 4
2013-03-14 22:16:43 PDT
Comment on
attachment 193228
[details]
Fixed the order. Clearing flags on attachment: 193228 Committed
r145873
: <
http://trac.webkit.org/changeset/145873
>
WebKit Review Bot
Comment 5
2013-03-14 22:16:46 PDT
All reviewed patches have been landed. Closing bug.
Daniel Freedman
Comment 6
2013-03-25 11:26:35 PDT
Sorry about the delay in looking at this, but I think the patch is backwards. As a reference, the URL I provided in the bug report (
http://jsfiddle.net/dfreedm/EMgtb/
) shows that for DOM construction host->{SR}->inner, with this patch applied, host will *always* see an event fired on inner *before* inner has a chance to see it. The expected result is that host will see all events, bubbling or not, on inner *after* inner sees it.
Hayato Ito
Comment 7
2013-03-25 19:09:08 PDT
Thank you for raising a question. (In reply to
comment #6
)
> Sorry about the delay in looking at this, but I think the patch is backwards. > > As a reference, the URL I provided in the bug report (
http://jsfiddle.net/dfreedm/EMgtb/
) shows that for DOM construction host->{SR}->inner, with this patch applied, host will *always* see an event fired on inner *before* inner has a chance to see it. >
That's an expected behavior in the spec. I think we should discuss this on Shadow DOM spec.
> The expected result is that host will see all events, bubbling or not, on inner *after* inner sees it.
Note that, before this patch, the parent node of host can see events on inner at its capturing phase before inner sees it. So there is still a chance that nodes on the outer tree can cancel an event on inner anyway with/without this patch.
Daniel Freedman
Comment 8
2013-03-26 01:09:48 PDT
(In reply to
comment #7
)
> Thank you for raising a question. > > (In reply to
comment #6
) > > Sorry about the delay in looking at this, but I think the patch is backwards. > > > > As a reference, the URL I provided in the bug report (
http://jsfiddle.net/dfreedm/EMgtb/
) shows that for DOM construction host->{SR}->inner, with this patch applied, host will *always* see an event fired on inner *before* inner has a chance to see it. > > > > That's an expected behavior in the spec. I think we should discuss this on Shadow DOM spec.
Will do.
> > > The expected result is that host will see all events, bubbling or not, on inner *after* inner sees it. > > Note that, before this patch, the parent node of host can see events on inner at its capturing phase before inner sees it. > So there is still a chance that nodes on the outer tree can cancel an event on inner anyway with/without this patch.
Agreed. I was imprecise in my last comment. I meant that I would expect that event listeners for the bubbling phase should fire in the inner, host order, no matter if event.bubbles is true or false.
Daniel Freedman
Comment 9
2013-03-26 12:01:18 PDT
(In reply to
comment #8
)
> (In reply to
comment #7
) > > Thank you for raising a question. > > > > (In reply to
comment #6
) > > > Sorry about the delay in looking at this, but I think the patch is backwards. > > > > > > As a reference, the URL I provided in the bug report (
http://jsfiddle.net/dfreedm/EMgtb/
) shows that for DOM construction host->{SR}->inner, with this patch applied, host will *always* see an event fired on inner *before* inner has a chance to see it. > > > > > > > That's an expected behavior in the spec. I think we should discuss this on Shadow DOM spec. > > Will do. > > > > > > The expected result is that host will see all events, bubbling or not, on inner *after* inner sees it. > > > > Note that, before this patch, the parent node of host can see events on inner at its capturing phase before inner sees it. > > So there is still a chance that nodes on the outer tree can cancel an event on inner anyway with/without this patch. > > Agreed. I was imprecise in my last comment. I meant that I would expect that event listeners for the bubbling phase should fire in the inner, host order, no matter if event.bubbles is true or false.
Filed
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21404
on Shadow DOM
Hayato Ito
Comment 10
2013-03-31 23:00:46 PDT
Let me close this bug. The discussion is on-going
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21404
. Looks like the desired behavior on the spec side is different than either before/after this patch. We should file a new bug in addition to updating the spec.
Hayato Ito
Comment 11
2013-03-31 23:26:14 PDT
Filed as
https://bugs.webkit.org/show_bug.cgi?id=113676
. (In reply to
comment #10
)
> Let me close this bug. > > The discussion is on-going
https://www.w3.org/Bugs/Public/show_bug.cgi?id=21404
. > > Looks like the desired behavior on the spec side is different than either before/after this patch. > We should file a new bug in addition to updating the spec.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug