Skip to content

Commit

Permalink
fix: compile attr:aria-* syntax (#2887)
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiaozero authored Aug 27, 2024
1 parent 58476bb commit 7dc58e2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions leptos_macro/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,12 @@ pub(crate) fn attribute_absolute(
node: &KeyedAttribute,
after_spread: bool,
) -> Option<TokenStream> {
let contains_dash = node.key.to_string().contains('-');
let key = node.key.to_string();
let contains_dash = key.contains('-');
let attr_aira = key.starts_with("attr:aria-");
// anything that follows the x:y pattern
match &node.key {
NodeName::Punctuated(parts) if !contains_dash => {
NodeName::Punctuated(parts) if !contains_dash || attr_aira => {
if parts.len() >= 2 {
let id = &parts[0];
match id {
Expand All @@ -566,6 +568,14 @@ pub(crate) fn attribute_absolute(
Some(
quote! { ::leptos::tachys::html::#key::#key(#value) },
)
} else if key_name == "aria" {
let mut parts_iter = parts.iter();
parts_iter.next();
let fn_name = parts_iter.map(|p| p.to_string()).collect::<Vec<String>>().join("_");
let key = Ident::new(&fn_name, key.span());
Some(
quote! { ::leptos::tachys::html::attribute::#key(#value) },
)
} else {
Some(
quote! { ::leptos::tachys::html::attribute::#key(#value) },
Expand Down

0 comments on commit 7dc58e2

Please sign in to comment.