-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference Target: Should the form
and list
JavaScript attributes return the host element?
#1072
Comments
I like option 2a the best, as long as changing the return type of those attributes can be done in a way that doesn't break the web. |
The behavior of the |
This is really thorny since some previous invariant cannot be satisfied. Either Option 3: Return the actual reference target element. This does not seem acceptable because it breaks encapsulation. I'm suggesting this as an option because the downside should be balanced against the downsides of the other options. Option 4: Return a proxy of the reference target element that appears as if it has no In the absence of these more exotic options being possible, I think just Option 1 returning |
This question was brought up by @mfreed7 in #1066 (comment).
In the JavaScript attributes that reflect Element objects section of the Reference Target Explainer, it describes how JavaScript attributes should return the host element, and not their reference target directly.
There are two attributes where this doesn't work today, because they are expected to return a specific element type:
.form
attribute always returns aHTMLFormElement
..list
attribute always returns aHTMLDataListElement
.In the following example, the submit button is successfully linked to the
<form id="real-form">
via the reference target. The question is what should the.form
JS attribute return?There are a few possible options:
.form
and.list
always returnnull
when used with a reference target. This way they never return something that's not the expected type..form
and.list
to be able to return anyHTMLElement
if (and only if) it has a reference target set.--
If we go with option 2, then that opens a secondary question that is related to the question posed in #1071:
What should it return if the reference target is not a valid
HTMLFormElement
/HTMLDataListElement
? For example:The options are:
2a. It returns
null
. Even though it refers to a valid host element, which has a valid reference target, the target element is the wrong type and there is no underlying association. This is the same as if you set theform=""
attribute to something that's not a<form>
.2b. It returns the host element. Presumably this would only happen if we went with Option 1b from #1071.
The text was updated successfully, but these errors were encountered: