- From: Mason Freed <notifications@github.com>
- Date: Tue, 13 Aug 2024 09:24:45 -0700
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/pull/1066/review/2236029043@github.com>
@mfreed7 commented on this pull request. > -These will _always_ refer to the **host** element that they're targeting, and _never_ the referenceTarget element directly. This behavior maintains the design that an [IDL attribute with type Element](https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:element) can only refer to an element that is a descendant of a [shadow-including ancestor](https://dom.spec.whatwg.org/#concept-shadow-including-ancestor) of the element hosting the attribute. +These will _never_ directly return the referenceTarget element that's inside the shadow tree. This is because an [IDL attribute with type Element](https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#reflecting-content-attributes-in-idl-attributes:element) can only refer to an element that is a descendant of a [shadow-including ancestor](https://dom.spec.whatwg.org/#concept-shadow-including-ancestor) of the element hosting the attribute. + +Instead, most attributes return the **host** element that they're targeting, as long as the attribute's expected type is `HTMLElement`. However, The `.form` and `.list` attributes will return `null` when used with a referenceTarget, because they are expected to be `HTMLFormElement` or `HTMLDataListElement` and the host element itself is not a form or datalist. Importantly, the underlying association will still exist: the input will be connected to the form, for example; it's just not reflected by the `.form` attribute. This feels a little odd, doesn't it? There **is** a form/list reference, and it's valid, but the JS accessor returns `null`. Perhaps it'd be better to have the IDL for `form` and `list` return `HTMLElement` (or even `Element`?)? I suppose there are likely web compat issues with this, of some variety. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/pull/1066#pullrequestreview-2236029043 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/pull/1066/review/2236029043@github.com>
Received on Tuesday, 13 August 2024 16:24:49 UTC