Skip to content

Conversation

@TakayoshiKochi
Copy link
Member

@TakayoshiKochi TakayoshiKochi commented Sep 15, 2017

Resolves #511.


Preview | Diff

@TakayoshiKochi
Copy link
Member Author

@annevk @hayatoito PTAL

@TakayoshiKochi
Copy link
Member Author

This should be accompanied with a corresponding layout test - will be created as a separate PR for WPT repository.

dom.bs Outdated
<li><p>Set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/NONE}}.

<li><p>Set <var>event</var>'s {{Event/target}} attribute to null if {{Event/target}}'s root is a
<a for=/>shadow root</a> and <var>event</var>'s <a>composed flag</a> is unset.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and event's composed flag is unset.

We should remove this condition.
We need to clear event.target even if composed flag is set because target and relatedTarget can be identical in the middle and event path can be trimmed for that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. So we can determine if the event is stopped at shadow root just by looking at whether target's root is a shadow root.

@hayatoito
Copy link
Member

This should be accompanied with a corresponding layout test - will be created as a separate PR for WPT repository.

Yeah, I am happy to review PR for WPT too.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll land this when we have the WPT PR. It would also be good to file browser bugs against Chrome and WebKit. Neither Edge nor Firefox has an implementation at the moment so that seems less needed.

@TakayoshiKochi
Copy link
Member Author

@hayatoito @annevk PTAL for relatedTarget addition.

Also, the corresponding WPT pull request is at
web-platform-tests/wpt#7481
(via https://chromium-review.googlesource.com/c/chromium/src/+/681894)

@annevk
Copy link
Member

annevk commented Oct 5, 2017

@TakayoshiKochi I don't quite know how relatedTarget works in all cases. Can we end up with a situation where target is null and relatedTarget is not? Or vice versa? Should we perhaps set both to null if either condition is true?

@annevk
Copy link
Member

annevk commented Oct 5, 2017

Also, is currentTarget affected?

dom.bs Outdated

<li><p>Set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/NONE}}.

<li><p>Set <var>event</var>'s {{Event/target}} attribute to null if {{Event/target}}'s root is a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should link "root" here and below as well.

@TakayoshiKochi
Copy link
Member Author

@TakayoshiKochi I don't quite know how relatedTarget works in all cases. Can we end up with a situation where target is null and relatedTarget is not? Or vice versa? Should we perhaps set both to null if either condition is true?

With the status quo, if an event bubbling ends up at a shadow root, its relatedTarget can be either in outside shadow tree or some shadow tree. If the former, target will become null but relatedTarget remain in my current spec patch - which may be weird and does not sound useful, even though it does not leak shadow tree.

On the other hand, once event.target is outside of any shadow tree, its corresponding relatedTarget should be also in the tree as a result of retargeting.

So I'm in favor of your idea, to set both to null if either condition is true.

Also, is currentTarget affected?

currentTarget is already covered in step 16 (in the original spec) so that it will be set to null.

If either condition is met, set target and relatedTarget to null.
@annevk
Copy link
Member

annevk commented Oct 5, 2017

Given what you're saying there, we only have to check target, right? Since relatedTarget is either equal or exposes less.

@TakayoshiKochi
Copy link
Member Author

Given what you're saying there, we only have to check target, right? Since relatedTarget is either equal or exposes less.

Absolutely. Thanks for pointing out.

@annevk
Copy link
Member

annevk commented Oct 5, 2017

Thanks, my last change request is to put the condition first. "If X, then set Y to Z." is generally how we write these steps.

Given there's tests I think this is ready to merge then. Thanks a lot!

dom.bs Outdated

<li><p>Set <var>event</var>'s {{Event/eventPhase}} attribute to {{Event/NONE}}.

<li><p>If {{Event/target}}'s <a for=tree>root</a> is a <a for=/>shadow root</a>, set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then set*

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Will add a test case there for relatedTarget is in document tree while target is in shadow tree and event stops at shadow root to make sure both are set to null.

@annevk annevk merged commit 9ada239 into whatwg:master Oct 5, 2017
@TakayoshiKochi TakayoshiKochi deleted the squashing_target branch October 5, 2017 08:27
@hayatoito
Copy link
Member

LGTM

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 6, 2017
This corresponds to the DOM spec change
whatwg/dom#513
not to leak elements inside shadow tree after event
dispatch is complete.

Bug: 771580, 762829
Change-Id: Ib77b4475c2c5bf174a6bcf3dc9f4dff583fd7d2a
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 6, 2017
This corresponds to the DOM spec change
whatwg/dom#513
not to leak elements inside shadow tree after event
dispatch is complete.

Bug: 771580, 762829
Change-Id: Ib77b4475c2c5bf174a6bcf3dc9f4dff583fd7d2a
Reviewed-on: https://chromium-review.googlesource.com/681894
Commit-Queue: Eriko Kurimoto <[email protected]>
Reviewed-by: Takayoshi Kochi <[email protected]>
Cr-Commit-Position: refs/heads/master@{#507013}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 6, 2017
This corresponds to the DOM spec change
whatwg/dom#513
not to leak elements inside shadow tree after event
dispatch is complete.

Bug: 771580, 762829
Change-Id: Ib77b4475c2c5bf174a6bcf3dc9f4dff583fd7d2a
Reviewed-on: https://chromium-review.googlesource.com/681894
Commit-Queue: Eriko Kurimoto <[email protected]>
Reviewed-by: Takayoshi Kochi <[email protected]>
Cr-Commit-Position: refs/heads/master@{#507013}
scheib pushed a commit to scheib/chromium that referenced this pull request Oct 7, 2017
This corresponds to the DOM spec change
whatwg/dom#513
not to leak elements inside shadow tree after event 
dispatch is complete.

Bug: 771580, 762829
Change-Id: Ib77b4475c2c5bf174a6bcf3dc9f4dff583fd7d2a
Reviewed-on: https://chromium-review.googlesource.com/681894
Commit-Queue: Eriko Kurimoto <[email protected]>
Reviewed-by: Takayoshi Kochi <[email protected]>
Cr-Commit-Position: refs/heads/master@{#507013}
jakearchibald pushed a commit to jakearchibald/web-platform-tests that referenced this pull request Nov 16, 2017
This corresponds to the DOM spec change
whatwg/dom#513
not to leak elements inside shadow tree after event
dispatch is complete.

Bug: 771580, 762829
Change-Id: Ib77b4475c2c5bf174a6bcf3dc9f4dff583fd7d2a
Reviewed-on: https://chromium-review.googlesource.com/681894
Commit-Queue: Eriko Kurimoto <[email protected]>
Reviewed-by: Takayoshi Kochi <[email protected]>
Cr-Commit-Position: refs/heads/master@{#507013}
nareix pushed a commit to nareix/webrtc.third_party that referenced this pull request Mar 5, 2018
This corresponds to the DOM spec change
whatwg/dom#513
not to leak elements inside shadow tree after event 
dispatch is complete.

Bug: 771580, 762829
Change-Id: Ib77b4475c2c5bf174a6bcf3dc9f4dff583fd7d2a
Reviewed-on: https://chromium-review.googlesource.com/681894
Commit-Queue: Eriko Kurimoto <[email protected]>
Reviewed-by: Takayoshi Kochi <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#507013}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 9c1d91c2ce388ffd5bfb0c005cd1c9f7016c7e3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants