diff --git a/leptos_dom/src/html.rs b/leptos_dom/src/html.rs index 137e3d715..59b0fa476 100644 --- a/leptos_dom/src/html.rs +++ b/leptos_dom/src/html.rs @@ -113,6 +113,11 @@ impl HtmlElement { "to set the `id`, please use `HtmlElement::id` instead" ); + assert_ne!( + name, "class", + "to set classes, please use `HtmlElement::class` instead" + ); + assert!( !self.attrs.iter().any(|(n, _)| n == &name), "attribute `{name}` already set" @@ -124,6 +129,13 @@ impl HtmlElement { self } + /// Sets a boolean attribute on the element, i.e., `checked`, or `disabled` in + /// `` + #[track_caller] + pub fn attr_bool(mut self, name: impl Into>) -> Self { + self.attr(name, "") + } + /// Inserts a child into this element. pub fn child(mut self, child: C) -> Self { self.children.push(Box::new(move |cx| child.into_node(cx)));