Summary
When Maud renders markup that mixes a literal class shorthand with a dynamic class=(...) attribute on the same element, it accepts the syntax but emits duplicate class attributes instead of merging them.
Reproduction
use maud::html;
fn main() {
let my_variable = "warning";
let markup = html! {
div.alert class=(my_variable) {}
}
.into_string();
assert_eq!(markup, r#"<div class=\"alert warning\"></div>"#);
}
Actual output
<div class="alert" class="warning"></div>
Expected output
<div class="alert warning"></div>
Why this matters
Duplicate attributes are not a stable contract. In local verification, HTML5-style parsers kept the first class attribute and ignored the later one, so browser-effective behavior was usually equivalent to:
<div class="alert"></div>
That means the dynamic class can be silently lost even though the Maud syntax is accepted.
Notes
I verified two things locally:
div.alert class=(my_variable) compiles successfully.
- Its rendered output is
<div class="alert" class="warning"></div>.
Summary
When Maud renders markup that mixes a literal class shorthand with a dynamic
class=(...)attribute on the same element, it accepts the syntax but emits duplicateclassattributes instead of merging them.Reproduction
Actual output
Expected output
Why this matters
Duplicate attributes are not a stable contract. In local verification, HTML5-style parsers kept the first
classattribute and ignored the later one, so browser-effective behavior was usually equivalent to:That means the dynamic class can be silently lost even though the Maud syntax is accepted.
Notes
I verified two things locally:
div.alert class=(my_variable)compiles successfully.<div class="alert" class="warning"></div>.