wip: groundwork for noderefs

This commit is contained in:
Jonathan Kelley committed 2021-08-09 17:09:33 -04:00
1 parent a44e9fcffa
commit c1afeba1ef
21 files changed
+184 -103

No files matched your search

+4 -8
View File
@@ -39,7 +39,8 @@ impl Parse for AmbiguousElement<AS_RSX> {
}
}
if let Ok(name) = input.fork().parse::<Ident>() {
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();
@@ -53,9 +54,6 @@ impl Parse for AmbiguousElement<AS_RSX> {
.map(|c| AmbiguousElement::Element(c))
}
} else {
if input.peek(LitStr) {
panic!("it's actually a litstr");
}
Err(Error::new(input.span(), "Not a valid Html tag"))
}
}
@@ -80,7 +78,8 @@ impl Parse for AmbiguousElement<AS_HTML> {
}
}
if let Ok(name) = input.fork().parse::<Ident>() {
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();
@@ -94,9 +93,6 @@ impl Parse for AmbiguousElement<AS_HTML> {
.map(|c| AmbiguousElement::Element(c))
}
} else {
if input.peek(LitStr) {
panic!("it's actually a litstr");
}
Err(Error::new(input.span(), "Not a valid Html tag"))
}
}
+6 -2
View File
@@ -32,6 +32,7 @@ impl Parse for Element<AS_RSX> {
let mut listeners: Vec<ElementAttr<AS_RSX>> = vec![];
let mut children: Vec<BodyNode<AS_RSX>> = vec![];
let mut key = None;
let mut el_ref = None;
'parsing: loop {
// [1] Break if empty
@@ -45,6 +46,7 @@ impl Parse for Element<AS_RSX> {
&mut attributes,
&mut listeners,
&mut key,
&mut el_ref,
name.clone(),
)?;
} else {
@@ -237,6 +239,7 @@ fn parse_rsx_element_field(
attrs: &mut Vec<ElementAttr<AS_RSX>>,
listeners: &mut Vec<ElementAttr<AS_RSX>>,
key: &mut Option<LitStr>,
el_ref: &mut Option<Expr>,
element_name: Ident,
) -> Result<()> {
let name = Ident::parse_any(stream)?;
@@ -311,8 +314,9 @@ fn parse_rsx_element_field(
"namespace" => {
todo!("custom namespace not supported")
}
"ref" => {
todo!("NodeRefs are currently not supported! This is currently a reserved keyword.")
"node_ref" => {
*el_ref = Some(stream.parse::<Expr>()?);
return Ok(());
}
// Fall through