Skip to content

Commit 7c92a19

Browse files
committed
add autocomplete attributes
fix #8
1 parent c7c4d8e commit 7c92a19

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1818
* implement `Default` for `Element` and `Attribute`
1919
* `attr::disabled()` and `attr::autofocus()`
2020
* `attr::charset_utf8()` and `elt::meta_charset_utf8()`
21+
* `attr::autocomplete(type_: impl Into<Cow<'static, str>>)`, `attr::autocomplete_on()`, `attr::autocomplete_off()`
2122

2223

2324
## [1.4.0] - 2024-12-13

src/attr.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,21 @@ pub fn autofocus() -> Attribute {
321321
Attribute::new_flag("autofocus")
322322
}
323323

324+
/// `autocomplete` attribute
325+
pub fn autocomplete(type_: impl Into<Cow<'static, str>>) -> Attribute {
326+
Attribute::new("autocomplete", type_)
327+
}
328+
329+
/// `autocomplete="on"` attribute
330+
pub fn autocomplete_on() -> Attribute {
331+
Attribute::new("autocomplete", "on")
332+
}
333+
334+
/// `autocomplete="on"` attribute
335+
pub fn autocomplete_off() -> Attribute {
336+
Attribute::new("autocomplete", "off")
337+
}
338+
324339
/// `disabled` attribute
325340
pub fn disabled() -> Attribute {
326341
Attribute::new_flag("disabled")

tests/render_spec.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ fn should_render_html_document() {
8787
#[case(attr::required(), "required")]
8888
#[case(attr::disabled(), "disabled")]
8989
#[case(attr::autofocus(), "autofocus")]
90+
#[case(attr::autocomplete("email"), "autocomplete=\"email\"")]
91+
#[case(attr::autocomplete_on(), "autocomplete=\"on\"")]
92+
#[case(attr::autocomplete_off(), "autocomplete=\"off\"")]
9093
#[case(attr::pattern("foobar"), "pattern=\"foobar\"")]
9194
#[case(attr::min("value"), "min=\"value\"")]
9295
#[case(attr::max("value"), "max=\"value\"")]

0 commit comments

Comments
 (0)