html icon indicating copy to clipboard operation
html copied to clipboard

Let Form-Associated Custom Elements match :required, :optional, and :autofill pseudo-selectors

Open NickGard opened this issue 9 months ago • 3 comments

What is the issue with the HTML Standard?

The spec as currently written does not include Form-Associated Custom Elements from matching:

Form-Associated Custom elements can match most of the other form-specific pseudo-selectors, like :disabled, :read-only, :read-write, :valid, and :invalid. Matching the rest of the form-specific pseudo-selectors would allow FA Custom Elements to behave more like their native counterparts.

NickGard avatar May 03 '24 20:05 NickGard

Also the :checked, :indeterminate, and :default pseudos.

NickGard avatar May 03 '24 20:05 NickGard

What is the use case for each in combination with FACE?

zcorpan avatar Jun 03 '24 14:06 zcorpan

What is the use case for each in combination with FACE?

<style>
  :required {
    border-color: red;
  }
</style>

<form>
  <label for="name">Name</label>
  <input id="name" required>
  <label for="email">Email</label>
  <custom-email-input id="email" required></custom-email-input>
</form>

I would expect the border-color to show on both inputs but the selector won't match the FACE. It would be cumbersome and fragile to have to add :state(required) and/or :state(my-FACE-required) for every rule that should match :required.

NickGard avatar Jun 07 '24 15:06 NickGard

Same usecase here: you'd want consumers of web components not having to know the details of how the web component was implemented, but just do what they normally do and things to 'just' work

So if they want to style all required form elements, that they can just use the :required pseudo-selector, instead of having to figure out for all the custom elements they might be using (now, but also in the future) how to properly target them using component-specific selectors

p-bakker avatar Sep 05 '24 10:09 p-bakker