mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 16:54:41 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a10ab613b8 |
@@ -23,8 +23,11 @@ use std::{
|
||||
collections::{HashMap, HashSet, VecDeque},
|
||||
};
|
||||
use syn::{
|
||||
spanned::Spanned, Expr, Expr::Tuple, ExprArray, ExprLit, ExprRange, Lit,
|
||||
LitStr, RangeLimits, Stmt,
|
||||
punctuated::Pair::{End, Punctuated},
|
||||
spanned::Spanned,
|
||||
Expr,
|
||||
Expr::Tuple,
|
||||
ExprArray, ExprLit, ExprRange, Lit, LitStr, RangeLimits, Stmt,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
@@ -998,10 +1001,10 @@ pub(crate) fn attribute_absolute(
|
||||
) -> Option<TokenStream> {
|
||||
let key = node.key.to_string();
|
||||
let contains_dash = key.contains('-');
|
||||
let attr_aira = key.starts_with("attr:aria-");
|
||||
let attr_colon = key.starts_with("attr:");
|
||||
// anything that follows the x:y pattern
|
||||
match &node.key {
|
||||
NodeName::Punctuated(parts) if !contains_dash || attr_aira => {
|
||||
NodeName::Punctuated(parts) if !contains_dash || attr_colon => {
|
||||
if parts.len() >= 2 {
|
||||
let id = &parts[0];
|
||||
match id {
|
||||
@@ -1010,7 +1013,8 @@ pub(crate) fn attribute_absolute(
|
||||
if id == "let" || id == "clone" {
|
||||
None
|
||||
} else if id == "attr" {
|
||||
let value = attribute_value(node, true);
|
||||
let value = attribute_value(node, true);
|
||||
let multipart = parts.len() > 2;
|
||||
let key = &parts[1];
|
||||
let key_name = key.to_string();
|
||||
if key_name == "class" || key_name == "style" {
|
||||
@@ -1026,6 +1030,15 @@ pub(crate) fn attribute_absolute(
|
||||
Some(
|
||||
quote! { ::leptos::tachys::html::attribute::#key(#value) },
|
||||
)
|
||||
} else if multipart {
|
||||
// e.g., attr:data-foo="bar"
|
||||
let key_name = parts.pairs().skip(1).map(|p| match p {
|
||||
Punctuated(n, p) => format!("{n}{p}"),
|
||||
End(n) => n.to_string(),
|
||||
}).collect::<String>();
|
||||
Some(
|
||||
quote! { ::leptos::tachys::html::attribute::custom::custom_attribute(#key_name, #value) },
|
||||
)
|
||||
} else {
|
||||
Some(
|
||||
quote! { ::leptos::tachys::html::attribute::#key(#value) },
|
||||
|
||||
Reference in New Issue
Block a user