Skip to content
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

Extend autocomplete attribute values #302

Closed
aronerben opened this issue Mar 10, 2022 · 3 comments
Closed

Extend autocomplete attribute values #302

aronerben opened this issue Mar 10, 2022 · 3 comments

Comments

@aronerben
Copy link
Contributor

aronerben commented Mar 10, 2022

Hello, thanks for this fantastic project!

Currently, the autocomplete attribute only supports on and off. The spec lists many more options. It would be nice if Tyxml supported those too! I don't know if this is already on the roadmap, or similar, so I decided to open this issue. :)

Encoding all possibilities mentioned in the spec with types seems a bit tedious (as there seem to be named groups, special cases for hidden input fields, etc.). Maybe simply turning it into a string attribute is "good enough" (I don't know what Tyxml's philosophy is here).

Currently we've solved it by unsafely adding the attribute like so:

let open Tyxml_xml in
let open Tyxml_html in
street_input
|> toelt
|> amap1 (fun _ attrs ->
      add_string_attrib "autocomplete" "street_address" attrs)
|> tot)

where street_input is some input field.

@Drup
Copy link
Member

Drup commented Mar 10, 2022

That specification is indeed pretty awkward, but I would prefer to avoid "just using a string". In this case, it seems we could start with a fairly simple model such as `On | `Off | `Tokens of string list and see where that leads us. In any case the ppx extension can check things in more details.

If you are willing, don't hesitate to submit a (potentially WIP) implementation ! There are instructions on how to add/change attributes in https://github.com/ocsigen/tyxml/blob/master/docs/Contributing.md . :)

@aronerben
Copy link
Contributor Author

@Drup Thanks for the quick response! I've drafted a PR: #303

@Drup
Copy link
Member

Drup commented Sep 27, 2023

Merged !

@Drup Drup closed this as completed Sep 27, 2023
Drup added a commit to Drup/opam-repository that referenced this issue Sep 29, 2023
CHANGES:

* Update for OCaml 5.0 and drop support for OCaml 4.2.0
  (ocsigen/tyxml#312 by @rr0gi)

* Add additional variants to `linktype` for the `rel` attribute
  (Leon @LogicalOverflow Vack)

* Expand options for `autocomplete` attribute on `<input>` elements
  (ocsigen/tyxml#302 by Aron @aronerben Erben)

* Fix the SVG element `<animate>` (by the way, deprecate `animation` et
  al. in favor of `animate` et al.)
  (ocsigen/tyxml#306 by Idir @ilankri Lankri)

* Add support for `dialog` element and `onclose` attribute
  (ocsigen/tyxml#301 by Julien Sagot)
* Add an escape hatch for emitting attributes with non-standard names
  in jsx or ppx code (a leading `_` character on attribute name)
  (ocsigen/tyxml#295 Chas @cemerick Emerick)
* Add support for `type` attribute on `<script>` elements
  (ocsigen/tyxml#293 by Ulrik @ulrikstrid Strid and Chas @cemerick Emerick)

* Add svg `fill-rule` attribute
  (ocsigen/tyxml#294 by Eric @dedbox Griffis)
nberth pushed a commit to nberth/opam-repository that referenced this issue Jun 18, 2024
CHANGES:

* Update for OCaml 5.0 and drop support for OCaml 4.2.0
  (ocsigen/tyxml#312 by @rr0gi)

* Add additional variants to `linktype` for the `rel` attribute
  (Leon @LogicalOverflow Vack)

* Expand options for `autocomplete` attribute on `<input>` elements
  (ocsigen/tyxml#302 by Aron @aronerben Erben)

* Fix the SVG element `<animate>` (by the way, deprecate `animation` et
  al. in favor of `animate` et al.)
  (ocsigen/tyxml#306 by Idir @ilankri Lankri)

* Add support for `dialog` element and `onclose` attribute
  (ocsigen/tyxml#301 by Julien Sagot)
* Add an escape hatch for emitting attributes with non-standard names
  in jsx or ppx code (a leading `_` character on attribute name)
  (ocsigen/tyxml#295 Chas @cemerick Emerick)
* Add support for `type` attribute on `<script>` elements
  (ocsigen/tyxml#293 by Ulrik @ulrikstrid Strid and Chas @cemerick Emerick)

* Add svg `fill-rule` attribute
  (ocsigen/tyxml#294 by Eric @dedbox Griffis)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants