Expand to a partial Component if a shorthand attribute starts with a capital letter (#2652)
This commit is contained in:
1 parent
7e279e5eb9
commit
163d66e9d7
1 file changed
+13
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user