Merge pull request #1812 from ealmloff/duplicate-event-listener-rsx

check for duplicate event listeners in the rsx macro
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-01-11 14:34:01 -08:00
commit 4f077ec664
4 files changed
+22 -20

No files matched your search

+21
View File
@@ -99,6 +99,27 @@ impl Parse for Element {
let span = content.span();
if name_str.starts_with("on") {
// check for any duplicate event listeners
if attributes.iter().any(|f| {
if let AttributeType::Named(ElementAttrNamed {
attr:
ElementAttr {
name: ElementAttrName::BuiltIn(n),
value: ElementAttrValue::EventTokens(_),
},
..
}) = f
{
n == &name_str
} else {
false
}
}) {
return Err(syn::Error::new(
name.span(),
format!("Duplicate event listener `{}`", name),
));
}
attributes.push(attribute::AttributeType::Named(ElementAttrNamed {
el_name: el_name.clone(),
attr: ElementAttr {