feat: cleanuup
This commit is contained in:
1 parent
fcc6738f17
commit
84fd0c6162
8 files changed
+37
-100
No files matched your search
@@ -15,6 +15,7 @@ use syn::{
|
||||
Error, Ident, Result, Token,
|
||||
};
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum AmbiguousElement<const AS: HtmlOrRsx> {
|
||||
Element(Element<AS>),
|
||||
Component(Component<AS>),
|
||||
@@ -30,7 +31,6 @@ impl Parse for AmbiguousElement<AS_RSX> {
|
||||
}
|
||||
|
||||
// If not an absolute path, then parse the ident and check if it's a valid tag
|
||||
|
||||
if let Ok(pat) = input.fork().parse::<syn::Path>() {
|
||||
if pat.segments.len() > 1 {
|
||||
return input
|
||||
@@ -80,57 +80,6 @@ impl Parse for AmbiguousElement<AS_HTML> {
|
||||
} else {
|
||||
Err(Error::new(input.span(), "Not a valid Html tag"))
|
||||
}
|
||||
|
||||
// input.parse::<Token![>]>()?;
|
||||
|
||||
// let mut children = Vec::new();
|
||||
// while !input.peek(Token![<]) {
|
||||
// children.push(input.parse::<BodyNode<AS_HTML>>()?);
|
||||
// }
|
||||
|
||||
// Ok(AmbiguousElement::Element(Element {
|
||||
// name,
|
||||
// key: todo!(),
|
||||
// attributes: todo!(),
|
||||
// listeners: todo!(),
|
||||
// children,
|
||||
// _is_static: todo!(),
|
||||
// }))
|
||||
|
||||
// // Try to parse as an absolute path and immediately defer to the componetn
|
||||
// if input.peek(Token![::]) {
|
||||
// return input
|
||||
// .parse::<Component<AS_HTML>>()
|
||||
// .map(AmbiguousElement::Component);
|
||||
// }
|
||||
|
||||
// // If not an absolute path, then parse the ident and check if it's a valid tag
|
||||
|
||||
// if let Ok(pat) = input.fork().parse::<syn::Path>() {
|
||||
// if pat.segments.len() > 1 {
|
||||
// return input
|
||||
// .parse::<Component<AS_HTML>>()
|
||||
// .map(AmbiguousElement::Component);
|
||||
// }
|
||||
// }
|
||||
|
||||
// use syn::ext::IdentExt;
|
||||
// if let Ok(name) = input.fork().call(Ident::parse_any) {
|
||||
// let name_str = name.to_string();
|
||||
|
||||
// let first_char = name_str.chars().next().unwrap();
|
||||
// if first_char.is_ascii_uppercase() {
|
||||
// input
|
||||
// .parse::<Component<AS_HTML>>()
|
||||
// .map(AmbiguousElement::Component)
|
||||
// } else {
|
||||
// input
|
||||
// .parse::<Element<AS_HTML>>()
|
||||
// .map(AmbiguousElement::Element)
|
||||
// }
|
||||
// } else {
|
||||
// Err(Error::new(input.span(), "Not a valid Html tag"))
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ impl Parse for Component<AS_HTML> {
|
||||
stream.parse::<Token![>]>()?;
|
||||
|
||||
'parsing: loop {
|
||||
if stream.peek(Token![<]) {
|
||||
if stream.peek(Token![<]) && stream.peek2(Token![/]) {
|
||||
break 'parsing;
|
||||
}
|
||||
|
||||
@@ -115,18 +115,6 @@ impl Parse for Component<AS_HTML> {
|
||||
}
|
||||
stream.parse::<Token![>]>()?;
|
||||
|
||||
// // parse the guts
|
||||
// let content: ParseBuffer;
|
||||
// syn::braced!(content in stream);
|
||||
|
||||
// let cfg: BodyConfig<AS_HTML> = BodyConfig {
|
||||
// allow_children: true,
|
||||
// allow_fields: true,
|
||||
// allow_manual_props: true,
|
||||
// };
|
||||
|
||||
// let (body, children, manual_props) = cfg.parse_component_body(&content)?;
|
||||
|
||||
Ok(Self {
|
||||
name,
|
||||
body,
|
||||
@@ -281,7 +269,7 @@ impl<const AS: HtmlOrRsx> ToTokens for Component<AS> {
|
||||
let mut __manual_props = #manual_props;
|
||||
};
|
||||
for field in &self.body {
|
||||
if field.name.to_string() == "key" {
|
||||
if field.name == "key" {
|
||||
has_key = Some(field);
|
||||
} else {
|
||||
let name = &field.name;
|
||||
@@ -301,7 +289,7 @@ impl<const AS: HtmlOrRsx> ToTokens for Component<AS> {
|
||||
None => {
|
||||
let mut toks = quote! { fc_to_builder(#name) };
|
||||
for field in &self.body {
|
||||
if field.name.to_string() == "key" {
|
||||
if field.name == "key" {
|
||||
has_key = Some(field);
|
||||
} else {
|
||||
toks.append_all(quote! {#field})
|
||||
|
||||
@@ -137,10 +137,11 @@ impl Parse for Element<AS_HTML> {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
stream.parse::<Token![>]>()?;
|
||||
|
||||
'parsing: loop {
|
||||
if stream.peek(Token![<]) {
|
||||
if stream.peek(Token![<]) && stream.peek2(Token![/]) {
|
||||
break 'parsing;
|
||||
}
|
||||
|
||||
@@ -155,6 +156,7 @@ impl Parse for Element<AS_HTML> {
|
||||
// closing element
|
||||
stream.parse::<Token![<]>()?;
|
||||
stream.parse::<Token![/]>()?;
|
||||
|
||||
let close = Ident::parse_any(stream)?;
|
||||
if close != el_name {
|
||||
return Err(Error::new_spanned(
|
||||
@@ -233,8 +235,6 @@ fn parse_rsx_element_field(
|
||||
// Return early if the field is a listener
|
||||
if name_str.starts_with("on") {
|
||||
// remove the "on" bit
|
||||
// name = Ident::new(&name_str.trim_start_matches("on"), name.span());
|
||||
|
||||
let ty = if stream.peek(token::Brace) {
|
||||
let content;
|
||||
syn::braced!(content in stream);
|
||||
@@ -293,7 +293,7 @@ fn parse_rsx_element_field(
|
||||
return Ok(());
|
||||
}
|
||||
"classes" => {
|
||||
todo!("custom class lsit not supported")
|
||||
todo!("custom class list not supported")
|
||||
}
|
||||
"namespace" => {
|
||||
todo!("custom namespace not supported")
|
||||
@@ -346,11 +346,11 @@ impl<const AS: HtmlOrRsx> ToTokens for ElementAttr<AS> {
|
||||
AttrType::BumpText(value) => tokens.append_all(quote! {
|
||||
dioxus_elements::#el_name.#nameident(__cx, format_args_f!(#value))
|
||||
}),
|
||||
|
||||
AttrType::FieldTokens(exp) => tokens.append_all(quote! {
|
||||
dioxus_elements::#el_name.#nameident(__cx, #exp)
|
||||
}),
|
||||
|
||||
// todo: move event handlers on to the elements or onto the nodefactory
|
||||
AttrType::Event(event) => tokens.append_all(quote! {
|
||||
dioxus::events::on::#nameident(__cx, #event)
|
||||
}),
|
||||
|
||||
@@ -17,7 +17,6 @@ mod component;
|
||||
mod element;
|
||||
mod fragment;
|
||||
mod node;
|
||||
mod parse_rsx;
|
||||
|
||||
// Re-export the namespaces into each other
|
||||
pub use ambiguous::*;
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
struct CallBody {}
|
||||
pub fn parse_callbody() {}
|
||||
Reference in new issue
Block a user