mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
fix: compile attr:aria-* syntax (#2887)
This commit is contained in:
parent
58476bb98e
commit
7dc58e248c
1 changed files with 12 additions and 2 deletions
|
@ -547,10 +547,12 @@ pub(crate) fn attribute_absolute(
|
||||||
node: &KeyedAttribute,
|
node: &KeyedAttribute,
|
||||||
after_spread: bool,
|
after_spread: bool,
|
||||||
) -> Option<TokenStream> {
|
) -> 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
|
// anything that follows the x:y pattern
|
||||||
match &node.key {
|
match &node.key {
|
||||||
NodeName::Punctuated(parts) if !contains_dash => {
|
NodeName::Punctuated(parts) if !contains_dash || attr_aira => {
|
||||||
if parts.len() >= 2 {
|
if parts.len() >= 2 {
|
||||||
let id = &parts[0];
|
let id = &parts[0];
|
||||||
match id {
|
match id {
|
||||||
|
@ -566,6 +568,14 @@ pub(crate) fn attribute_absolute(
|
||||||
Some(
|
Some(
|
||||||
quote! { ::leptos::tachys::html::#key::#key(#value) },
|
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 {
|
} else {
|
||||||
Some(
|
Some(
|
||||||
quote! { ::leptos::tachys::html::attribute::#key(#value) },
|
quote! { ::leptos::tachys::html::attribute::#key(#value) },
|
||||||
|
|
Loading…
Reference in a new issue