diff --git a/packages/yew-macro/src/derive_props/field.rs b/packages/yew-macro/src/derive_props/field.rs index 91e2ba08fad..9654a6e25d2 100644 --- a/packages/yew-macro/src/derive_props/field.rs +++ b/packages/yew-macro/src/derive_props/field.rs @@ -200,7 +200,7 @@ pub struct PropFieldCheck<'a> { check_arg: GenericParam, } -impl<'a> PropFieldCheck<'a> { +impl PropFieldCheck<'_> { pub fn to_fake_prop_decl(&self) -> proc_macro2::TokenStream { let Self { this, .. } = self; if !this.is_required() { diff --git a/packages/yew-macro/src/html_tree/html_element.rs b/packages/yew-macro/src/html_tree/html_element.rs index ee588305de6..c5db2121f26 100644 --- a/packages/yew-macro/src/html_tree/html_element.rs +++ b/packages/yew-macro/src/html_tree/html_element.rs @@ -11,6 +11,45 @@ use crate::props::{ElementProps, Prop, PropDirective}; use crate::stringify::{Stringify, Value}; use crate::{is_ide_completion, non_capitalized_ascii, Peek, PeekValue}; +fn is_normalised_element_name(name: &str) -> bool { + match name { + "animateMotion" + | "animateTransform" + | "clipPath" + | "feBlend" + | "feColorMatrix" + | "feComponentTransfer" + | "feComposite" + | "feConvolveMatrix" + | "feDiffuseLighting" + | "feDisplacementMap" + | "feDistantLight" + | "feDropShadow" + | "feFlood" + | "feFuncA" + | "feFuncB" + | "feFuncG" + | "feFuncR" + | "feGaussianBlur" + | "feImage" + | "feMerge" + | "feMergeNode" + | "feMorphology" + | "feOffset" + | "fePointLight" + | "feSpecularLighting" + | "feSpotLight" + | "feTile" + | "feTurbulence" + | "foreignObject" + | "glyphRef" + | "linearGradient" + | "radialGradient" + | "textPath" => true, + _ => !name.chars().any(|c| c.is_ascii_uppercase()), + } +} + pub struct HtmlElement { pub name: TagName, pub props: ElementProps, @@ -310,9 +349,9 @@ impl ToTokens for HtmlElement { TagName::Lit(dashedname) => { let name_span = dashedname.span(); let name = dashedname.to_ascii_lowercase_string(); - if name != dashedname.to_string() { + if !is_normalised_element_name(&dashedname.to_string()) { emit_warning!( - dashedname.span(), + name_span.clone(), format!( "The tag '{dashedname}' is not matching its normalized form '{name}'. If you want \ to keep this form, change this to a dynamic tag `@{{\"{dashedname}\"}}`." diff --git a/packages/yew-macro/tests/html_macro_test.rs b/packages/yew-macro/tests/html_macro_test.rs index 69d62934bfa..7b410d8aa63 100644 --- a/packages/yew-macro/tests/html_macro_test.rs +++ b/packages/yew-macro/tests/html_macro_test.rs @@ -35,7 +35,7 @@ fn dynamic_tags_catch_non_ascii() { #[test] fn html_nested_macro_on_html_element() { let _node = html_nested! { -
+