spectrum-web-components icon indicating copy to clipboard operation
spectrum-web-components copied to clipboard

Loosen API for form inputs?

Open adbehahn opened this issue 3 years ago • 1 comments

Code of conduct

  • [X] I agree to follow this project's code of conduct.

Description of issue

sp-checkbox doesn't expose a "name" attribute in its API:

            <input
                id="input"
                aria-labelledby="label"
                type="checkbox"
                .checked=${this.checked}
                @change=${this.handleChange}
            />

I was wondering if either 1) name could be added to the API or 2) all properties that aren't used exclusively by the wrapping component could be passed through to the input.

Same thought applies to all inputs wrapped by Spectrum.

As a coder, a goal would be to leverage built-in Javascript API's and therefore be able to write simpler and less risky code, such as:

const formData = new FormData(form);

adbehahn avatar Jun 20 '22 21:06 adbehahn

Notes:

  • this likely would benefit from https://github.com/open-wc/form-participation
  • ☝🏼 relies (correctly) on elementInternals which is not yet available everywhere, but can be polyfilled via: https://www.npmjs.com/package/element-internals-polyfill
  • attachInternals also opens up attribute free (sans polyfill) aria value application, which @joekukish is interested in and relates to #1742

Westbrook avatar Jun 29 '22 16:06 Westbrook