Merge branch 'master' into router-typesafe

This commit is contained in:
Evan Almloff committed 2023-07-07 18:31:48 -07:00
commit 05fb8c1e91
226 files changed
+18429 -706

No files matched your search

+18 -20
View File
@@ -231,30 +231,28 @@ impl Parse for ComponentField {
let name = Ident::parse_any(input)?;
input.parse::<Token![:]>()?;
if name.to_string().starts_with("on") {
let content = ContentField::OnHandlerRaw(input.parse()?);
return Ok(Self { name, content });
}
if name == "key" {
let content = ContentField::Formatted(input.parse()?);
return Ok(Self { name, content });
}
if input.peek(LitStr) {
let forked = input.fork();
let t: LitStr = forked.parse()?;
// the string literal must either be the end of the input or a followed by a comma
if (forked.is_empty() || forked.peek(Token![,])) && is_literal_foramtted(&t) {
let content = {
if name.to_string().starts_with("on") {
ContentField::OnHandlerRaw(input.parse()?)
} else if name == "key" {
let content = ContentField::Formatted(input.parse()?);
return Ok(Self { name, content });
} else if input.peek(LitStr) {
let forked = input.fork();
let t: LitStr = forked.parse()?;
// the string literal must either be the end of the input or a followed by a comma
if (forked.is_empty() || forked.peek(Token![,])) && is_literal_foramtted(&t) {
ContentField::Formatted(input.parse()?)
} else {
ContentField::ManExpr(input.parse()?)
}
} else {
ContentField::ManExpr(input.parse()?)
}
};
if input.peek(LitStr) || input.peek(Ident) {
missing_trailing_comma!(content.span());
}
if input.peek(LitStr) && input.peek2(LitStr) {
missing_trailing_comma!(input.span());
}
let content = ContentField::ManExpr(input.parse()?);
Ok(Self { name, content })
}
}
+5 -2
View File
@@ -75,11 +75,14 @@ impl Parse for Element {
if content.peek(Ident) && content.peek2(Token![:]) && !content.peek3(Token![:]) {
let name = content.parse::<Ident>()?;
let ident = name.clone();
let name_str = name.to_string();
content.parse::<Token![:]>()?;
// The span of the content to be parsed,
// for example the `hi` part of `class: "hi"`.
let span = content.span();
if name_str.starts_with("on") {
attributes.push(ElementAttrNamed {
el_name: el_name.clone(),
@@ -126,7 +129,7 @@ impl Parse for Element {
// todo: add a message saying you need to include commas between fields
if content.parse::<Token![,]>().is_err() {
missing_trailing_comma!(ident.span());
missing_trailing_comma!(span);
}
continue;
}