silenced non-normalised element name warnings for SVG elements (#3769)

This commit is contained in:
Tim Kurdov 2024-12-13 08:40:14 +00:00 committed by GitHub
parent 6bec0ec56a
commit 2362fad729
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 44 additions and 6 deletions

View File

@ -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() {

View File

@ -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}\"}}`."

View File

@ -35,7 +35,7 @@ fn dynamic_tags_catch_non_ascii() {
#[test]
fn html_nested_macro_on_html_element() {
let _node = html_nested! {
<div/>
<feBlend/>
};
let _node = html_nested! {
<input/>

View File

@ -54,7 +54,7 @@ struct NodeWriter<'s> {
slot: DomSlot,
}
impl<'s> NodeWriter<'s> {
impl NodeWriter<'_> {
/// Write a new node that has no ancestor
fn add(self, node: VNode) -> (Self, BNode) {
test_log!("adding: {:?}", node);

View File

@ -49,7 +49,6 @@ pub(crate) struct Bundle(BNode);
impl Bundle {
/// Creates a new bundle.
pub const fn new() -> Self {
Self(BNode::List(BList::new()))
}