Add reference target#10995
Conversation
|
@annevk, @domenic, this isn't quite ready to land yet as there are still a few open questions to sort out (at least WICG/webcomponents#1087 and WICG/webcomponents#1093), plus missing implementor positions. But I don't expect most of the mechanics in this PR to change, so I think it would be great to get feedback on whether the approach we've used here is agreeable. See also whatwg/dom#1353 Thanks! |
|
There's also a WIP PR against ARIA to account for these changes: w3c/aria#2474 There are some open questions being discussed there on exactly how to refer to the HTML concepts, since ARIA needs to be language-independent, but it will certainly refer to these spec concepts in some form. |
This concept is used to propagate events into the source's tree under certain circumstances.
lukewarlow
left a comment
There was a problem hiding this comment.
This should be updated to make use of the new [Reflect] syntax.
Thanks @lukewarlow! Fixed now (it wouldn't let me merge the suggestions directly due to merge conflicts). |
|
I'm not sure how GitHub actually lets you dismiss change suggestions but consider this me dropping my change suggestions as they've been resolved :) |
keithamus
left a comment
There was a problem hiding this comment.
I've done an initial review pass, got about half way, but I thought I'd provide my review commentary so far because I think if I continue I may end up repeating themes.
Some meta commentary:
- I think another formatting pass needs to be done.
- I am a little worried about the retargeting steps, I wonder if this can be simplified to avoid retargeting and to resolve a reference target where necessary.
| <span>tree</span>.</p> | ||
| a valid <span>single element reference</span> attribute | ||
| <span data-x="single-element-reference-refers-to">referring to</span> a <code>form</code> | ||
| element.</p> |
There was a problem hiding this comment.
This isn't perhaps super clear. I think this means that the final element from single element reference should be a form element
There was a problem hiding this comment.
That's right. I'm not really sure of a clearer way to put it.
There was a problem hiding this comment.
I wonder if this all works well for the Developer Edition of the standard as now we're phrasing conformance requirements in terms of algorithms aimed at implementers?
alice
left a comment
There was a problem hiding this comment.
I had to apply all the code suggestions manually, because I foolishly pushed my changes before I'd applied them.
| [<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute DOMString <dfn attribute for="HTMLObjectElement" data-x="dom-object-type">type</dfn>; | ||
| [<span>CEReactions</span>, <span data-x="xattr-Reflect">Reflect</span>] attribute DOMString <dfn attribute for="HTMLObjectElement" data-x="dom-object-name">name</dfn>; | ||
| readonly attribute <span>HTMLFormElement</span>? <span data-x="dom-fae-form">form</span>; | ||
| readonly attribute <span>HTMLElement</span>? <span data-x="dom-fae-form">form</span>; |
There was a problem hiding this comment.
How does this work if we say it has to be Element above? (Not the only occurrence it seems.)
There was a problem hiding this comment.
I think it was a mistake for the type to be Element above; I've changed it to Element?. So that should fit with the usage here and elsewhere.
There was a problem hiding this comment.
I think you misunderstood my comment here. This was specifically talking about the mismatch between Element and HTMLElement.
There was a problem hiding this comment.
Ah, sorry, I understand now.
This (and the other IDL form attributes like it) isn't defined as a reflecting attribute, so it doesn't depend on the "If a reflected IDL attribute has the type Element?" algorithm, so the type doesn't need to match with that. This has its own definition from further down in the spec, which this PR also modifies to be:
Listed form-associated elements except for form-associated custom elements have a form IDL attribute, which, on getting, must return the result of retargeting the element's form owner against the element, or null if there isn't a form owner.
I think in practice this would always end up being an HTMLElement, since it will either be the actual HTMLFormElement or it'll be a shadow host due to retargeting, and currently only HTMLElement can be a shadow host due to the namespace check in step 1 of attach a shadow root.
But on the other hand:
- It's confusing for this to be
HTMLElementsince the related algorithms all deal inElements - Non-
HTMLElements can be shadow hosts in Blink due to an apparently-longstanding bug - Maybe someday we'll want to deliberately allow certain non-HTML-elements to be shadow hosts.
So all-in-all you're probably right that these should just be Element. I've updated all the occurrences.
| slot (or map of additional fields) is required to properly specify this.</p> | ||
|
|
||
| <p>The <code data-x="dom-ToggleEvent-source">source</code> attribute defines the <span | ||
| data-x="concept-event-source">source</span> for a <code>ToggleEvent</code>.</p> |
There was a problem hiding this comment.
This is too much action-at-a-distance. We need to actually define this at dispatch time.
There was a problem hiding this comment.
Acknowledged. I'll work on this.
|
Alice, Jake, Olli, and I discussed the event model again. Here's the concrete proposal:
|
|
@annevk I think this basically makes sense. There are a couple details I'm unclear on about setting the event to composed.
|
|
@dandclark thanks, for 1) I think our assessment is that websites are highly unlikely to rely on the Fire an event does run into whatwg/dom#1328 which I think @keithamus wanted to look into, but should probably not block this. Maybe we want to add a source comment ( |
…ire a focus event to pass relatedTarget to be set as concept rather than attribute
…mmand are fired, set composed and relatedTarget.
|
@annevk Ok, I pushed those changes to this and the DOM spec PR (whatwg/dom#1353). In these changes I'm trying to draw a distinction between Event's internal relatedTarget concept and the |
| data-x="dom-ToggleEvent-source">source</code> against <span>this</span>'s <code | ||
| data-x="dom-Event-currentTarget">currentTarget</code>.</p> | ||
| data-x="dom-ToggleEvent-source">source</code></dfn> getter steps are to return | ||
| <span>this</span>'s <span data-x="concept-event-relatedTarget">relatedTarget</span>.</p> |
There was a problem hiding this comment.
How does this work for synthetic events. Should we remove the source member from IDL or do we allow an explicitly-set source to win somehow? (Same for the other events.) Needs test coverage as well.
There was a problem hiding this comment.
The simplest thing could be that when source is set on a synthetic event (new CommandEvent('command', {source: someElement} etc), it sets the actual Event relatedTarget concept, just like with non-synthetic events that have a source. So it could affect the event path, and could be retargeted during dispatch.
The downside of this would be compatability. Devs can already create synthetic events today without the use of reference target whose dispatch behavior would be affected by this. Are there other reasons not to prefer that approach?
If that sounds bad due to the compat issue or for other reasons, seems reasonable to have something like an explicitly-set source that doesn't touch relatedTarget but that could be reflected in the IDL attribute.
|
I think making relatedTarget a (named) parameter is a good idea. |
Reference Target allows authors to specify an element inside a shadow root to be the target of any ID references referring to the host element. This would enable IDREF attributes such as for and aria-labelledby to refer to elements inside a component's shadow DOM while maintaining encapsulation of the internal details of the shadow DOM.
See the reference target explainer.
At a high level, the spec change consists of these parts:
get-the-attr-associated-elementalgorithm (and its array-of-elements form) to follow reference target.get-the-attr-associated-element.See also the corresponding whatwg/dom#1353 which adds the definition of reference target used in this PR.
(See WHATWG Working Mode: Changes for more details.)
/common-dom-interfaces.html ( diff )
/common-microsyntaxes.html ( diff )
/document-lifecycle.html ( diff )
/dom.html ( diff )
/form-control-infrastructure.html ( diff )
/form-elements.html ( diff )
/forms.html ( diff )
/iframe-embed-object.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/input.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/links.html ( diff )
/microdata.html ( diff )
/nav-history-apis.html ( diff )
/parsing.html ( diff )
/popover.html ( diff )
/scripting.html ( diff )
/tables.html ( diff )