Expand to a partial Component if a shorthand attribute starts with a capital letter (#2652)

This commit is contained in:
Evan Almloff authored and GitHub committed 2024-07-23 10:57:15 -07:00
1 parent 7e279e5eb9
commit 163d66e9d7
1 file changed
+13 -2
+13 -2
View File
@@ -139,8 +139,19 @@ impl RsxBlock {
// Parse shorthand attributes
// todo: this might cause complications with partial expansion... think more about the cases
// where we can imagine expansion and what better diagnostics we can providea
if content.peek(Ident)
// where we can imagine expansion and what better diagnostics we can provide
let looks_like_attribute = match content.fork().parse::<Ident>() {
// If it is an ident, it is only a shorthand attribute if it starts with a lowercase letter
// Otherwise this is the start of a component
Ok(ident) => ident
.to_string()
.chars()
.next()
.unwrap()
.is_ascii_lowercase(),
Err(_) => false,
};
if looks_like_attribute
&& !content.peek2(Brace)
&& !content.peek2(Token![:]) // regular attributes / components with generics
&& !content.peek2(Token![-]) // web components