diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a43da7..a96a677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * implement `Default` for `Element` and `Attribute` * `attr::disabled()` and `attr::autofocus()` * `attr::charset_utf8()` and `elt::meta_charset_utf8()` +* `attr::autocomplete(type_: impl Into>)`, `attr::autocomplete_on()`, `attr::autocomplete_off()` ## [1.4.0] - 2024-12-13 diff --git a/src/attr.rs b/src/attr.rs index f7d0428..a12ce95 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -321,6 +321,21 @@ pub fn autofocus() -> Attribute { Attribute::new_flag("autofocus") } +/// `autocomplete` attribute +pub fn autocomplete(type_: impl Into>) -> Attribute { + Attribute::new("autocomplete", type_) +} + +/// `autocomplete="on"` attribute +pub fn autocomplete_on() -> Attribute { + Attribute::new("autocomplete", "on") +} + +/// `autocomplete="on"` attribute +pub fn autocomplete_off() -> Attribute { + Attribute::new("autocomplete", "off") +} + /// `disabled` attribute pub fn disabled() -> Attribute { Attribute::new_flag("disabled") diff --git a/tests/render_spec.rs b/tests/render_spec.rs index abc25f0..d8b1105 100644 --- a/tests/render_spec.rs +++ b/tests/render_spec.rs @@ -87,6 +87,9 @@ fn should_render_html_document() { #[case(attr::required(), "required")] #[case(attr::disabled(), "disabled")] #[case(attr::autofocus(), "autofocus")] +#[case(attr::autocomplete("email"), "autocomplete=\"email\"")] +#[case(attr::autocomplete_on(), "autocomplete=\"on\"")] +#[case(attr::autocomplete_off(), "autocomplete=\"off\"")] #[case(attr::pattern("foobar"), "pattern=\"foobar\"")] #[case(attr::min("value"), "min=\"value\"")] #[case(attr::max("value"), "max=\"value\"")]