Revert "fix: Fixes boolean attributes in HTML fast-path (closes issue #405)"

This reverts commit 2ecb345a79.
This commit is contained in:
Greg Johnston 2023-01-29 16:27:28 -05:00
parent 2ecb345a79
commit 116d23f2c3
2 changed files with 10 additions and 20 deletions

View file

@ -49,9 +49,9 @@ impl Attribute {
/// Converts the attribute to its HTML value at that moment, not including
/// the attribute name, so it can be rendered on the server.
pub fn as_nameless_value_string(&self) -> Option<String> {
pub fn as_nameless_value_string(&self) -> String {
match self {
Attribute::String(value) => Some(value.to_string()),
Attribute::String(value) => value.to_string(),
Attribute::Fn(_, f) => {
let mut value = f();
while let Attribute::Fn(_, f) = value {
@ -59,16 +59,11 @@ impl Attribute {
}
value.as_nameless_value_string()
}
Attribute::Option(_, value) => {
value.as_ref().map(|value| value.to_string())
}
Attribute::Bool(include) => {
if *include {
Some("".to_string())
} else {
None
}
}
Attribute::Option(_, value) => value
.as_ref()
.map(|value| value.to_string())
.unwrap_or_default(),
Attribute::Bool(_) => String::new(),
}
}
}

View file

@ -435,13 +435,10 @@ fn attribute_to_tokens_ssr(
template.push_str(&value);
template.push('"');
} else {
template.push_str("{}");
template.push_str("=\"{}\"");
let value = value.as_ref();
holes.push(quote! {
&{#value}.into_attribute(#cx)
.as_nameless_value_string()
.map(|a| format!("{}=\"{}\"", #name, a))
.unwrap_or_default(),
leptos::escape_attr(&{#value}.into_attribute(#cx).as_nameless_value_string()),
})
}
}
@ -558,9 +555,7 @@ fn set_class_attribute_ssr(
template.push_str(" {}");
let value = value.as_ref();
holes.push(quote! {
match &(cx, #value).into_attribute(#cx).as_nameless_value_string()
.map(|a| leptos::escape_attr(&a).to_string())
.unwrap_or_default(),
leptos::escape_attr(&(cx, #value).into_attribute(#cx).as_nameless_value_string()),
});
}
}