- From: Ben Howell <notifications@github.com>
- Date: Wed, 14 Aug 2024 15:13:39 -0700
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/pull/1066/review/2239281810@github.com>
@behowell 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. Yeah I agree it seems odd. My main concern was worrying not to break the web by changing the return type to `HTMLElement` instead of `HTMLFormElement`/`HTMLDataListElement`. That said, the change would only affect new scenarios that were previously not possible, and it should not affect existing code as far as I can tell. It would be good to have an expert weigh in on the potential problems with changing the IDL return types in the new scenarios. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/pull/1066#discussion_r1717606135 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/pull/1066/review/2239281810@github.com>
Received on Wednesday, 14 August 2024 22:13:44 UTC