Add reference target to shadow root#1353
Conversation
- Add the concept of a "source" for an Event. - Modify shadow root's "get the parent" algorithm such that events propagate into the event's source's tree where appropriate.
|
@annevk , @smaug---- , this is ready for another review along with whatwg/html#10995. For context on the event propagation change, see WICG/webcomponents#1098. Thanks! |
|
What is the current testing situation? alice added several tests, but this is a rather complicated feature (at least from implementation point of view) so we need to ensure testing coverage is particularly good. But are we testing all the complicated cases? |
|
I've tried to ensure that the WPTs for this are thorough; I and other contributors added quite a few during work on the Chromium prototype. E.g. https://wpt.fyi/results/shadow-dom/reference-target/tentative/property-reflection.html and https://wpt.fyi/results/shadow-dom/reference-target/tentative/property-reflection-idl-setters.html test reflection behavior for all the properties affected by reference target, with references pointing to and from every HTML element type. https://github.com/web-platform-tests/wpt/blob/master/shadow-dom/reference-target/tentative/event-path.html covers all the interesting event propagation scenarios discussed in WICG/webcomponents#1098, plus some others I thought of. All of the platform features testable in WPTs that can be affected by reference target (form submission, There are a few other ARIA properties affected by reference target that aren't yet testable in WPTs; there are tests for those in the Chromium source tree at https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/shadow-dom/reference-target/tentative/. For some reason it doesn't seem like the Mozilla CI results are including the full set of tests. There are a larger number of tests in https://wpt.fyi/results/shadow-dom/reference-target/tentative that Gecko is shown as failing that don't appear in the linked Mozilla CI results. |
|
The pref in Gecko isn't enabled in Nightly, so wpt.fyi still shows many tests as failing. The pref is enabled in Mozilla CI. |
| <ol> | ||
| <li><p>If <var>event</var>’s <a>composed flag</a> is set, return <a for=/>shadow root</a>’s | ||
| <a for=DocumentFragment>host</a>.</p></li> | ||
| <li><p>Let <var>target</var> be <var>event</var>’s <a for=Event>path</a>'s first struct's |
| <var>source</var>, return <a for=/>shadow root</a>'s <a for=DocumentFragment>host</a>.</p></li> | ||
| <li><p>If <var>source</var> is not null, and <var>source</var>'s <a for=tree>root</a> is a | ||
| <a>shadow-including ancestor</a> of <a for=/>shadow root</a>, return the result of | ||
| <a>retargeting</a> <var>target</var> against <var>source</var>.</p></li> |
There was a problem hiding this comment.
I wonder if we should add one or two examples here because this is getting rather involved. It seems really weird that as part of calculating the dispatch tree we are retargeting.
Also just to return the event target as the parent of the shadow tree. I can't really wrap my head around this.
There was a problem hiding this comment.
This in particular I would expect to have test coverage for every branch in detail. Including capture and bubble phases, the works. Does that exist?
| <code>relatedTarget</code> attribute. [[UIEVENTS]] | ||
|
|
||
| <p>An <a>event</a> has an associated <dfn export for=Event>source</dfn> (a | ||
| <a>potential event target</a>). Unless stated otherwise it is null. |
There was a problem hiding this comment.
This should probably have a note explaining where this is used. "Other specifications ..."
|
|
||
| <li><p>If <var>source</var> is not null, and <var>source</var>'s <a for=tree>root</a> is a | ||
| <a>shadow-including ancestor</a> of <var>shadowRoot</var>, then return the result of | ||
| <a>retargeting</a> <var>target</var> against <var>source</var>. |
There was a problem hiding this comment.
As I said in WICG/webcomponents#1098 (comment) I think we should still investigate relatedTarget model for this. Basically, the relevant events would be composed but propagate only up to the level where .target and .source are different.
Reference Target is a feature to enable using IDREF attributes such as
forandaria-labelledbyto refer to elements inside a component's shadow DOM, while maintaining encapsulation of the internal details of the shadow DOM. The main goal of this feature is to enable ARIA to work across shadow root boundaries.In this change, add the
referenceTargetproperty toShadowRootand add a definition ofreference targetthat's exported for use in other specs.See the reference target explainer.
Preview | Diff