Skip to content

Commit

Permalink
add disabled and autofocus attributes
Browse files Browse the repository at this point in the history
fix #10
fix #9
  • Loading branch information
jcornaz committed Dec 16, 2024
1 parent cde262c commit 8dc04bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ pub fn value(value: impl Into<Cow<'static, str>>) -> 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<Cow<'static, str>>) -> Attribute {
Expand Down
2 changes: 2 additions & 0 deletions tests/render_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\"")]
Expand Down

0 comments on commit 8dc04bb

Please sign in to comment.