diff --git a/CHANGELOG.md b/CHANGELOG.md index 015b174..7a5c9f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * `attr::none()` for conditional rendering of an attribute * implement `Default` for `Element` and `Attribute` - +* `attr::disabled()` and `attr::autofocus()` ## [1.4.0] - 2024-12-13 diff --git a/src/attr.rs b/src/attr.rs index c02ea5c..a31f44b 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -310,6 +310,15 @@ pub fn value(value: impl Into>) -> Attribute { pub fn required() -> Attribute { Attribute::new_flag("required") } +/// `autofocus` attribute +pub fn autofocus() -> Attribute { + Attribute::new_flag("autofocus") +} + +/// `disabled` attribute +pub fn disabled() -> Attribute { + Attribute::new_flag("disabled") +} /// `pattern` attribute pub fn pattern(value: impl Into>) -> Attribute { diff --git a/tests/render_spec.rs b/tests/render_spec.rs index cd2afb7..fcf69d7 100644 --- a/tests/render_spec.rs +++ b/tests/render_spec.rs @@ -83,6 +83,8 @@ fn should_render_html_document() { #[case(attr::for_("foo"), "for=\"foo\"")] #[case(attr::value("hello"), "value=\"hello\"")] #[case(attr::required(), "required")] +#[case(attr::disabled(), "disabled")] +#[case(attr::autofocus(), "autofocus")] #[case(attr::pattern("foobar"), "pattern=\"foobar\"")] #[case(attr::min("value"), "min=\"value\"")] #[case(attr::max("value"), "max=\"value\"")]