mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
silenced non-normalised element name warnings for SVG elements (#3769)
This commit is contained in:
parent
6bec0ec56a
commit
2362fad729
@ -200,7 +200,7 @@ pub struct PropFieldCheck<'a> {
|
|||||||
check_arg: GenericParam,
|
check_arg: GenericParam,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PropFieldCheck<'a> {
|
impl PropFieldCheck<'_> {
|
||||||
pub fn to_fake_prop_decl(&self) -> proc_macro2::TokenStream {
|
pub fn to_fake_prop_decl(&self) -> proc_macro2::TokenStream {
|
||||||
let Self { this, .. } = self;
|
let Self { this, .. } = self;
|
||||||
if !this.is_required() {
|
if !this.is_required() {
|
||||||
|
|||||||
@ -11,6 +11,45 @@ use crate::props::{ElementProps, Prop, PropDirective};
|
|||||||
use crate::stringify::{Stringify, Value};
|
use crate::stringify::{Stringify, Value};
|
||||||
use crate::{is_ide_completion, non_capitalized_ascii, Peek, PeekValue};
|
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 struct HtmlElement {
|
||||||
pub name: TagName,
|
pub name: TagName,
|
||||||
pub props: ElementProps,
|
pub props: ElementProps,
|
||||||
@ -310,9 +349,9 @@ impl ToTokens for HtmlElement {
|
|||||||
TagName::Lit(dashedname) => {
|
TagName::Lit(dashedname) => {
|
||||||
let name_span = dashedname.span();
|
let name_span = dashedname.span();
|
||||||
let name = dashedname.to_ascii_lowercase_string();
|
let name = dashedname.to_ascii_lowercase_string();
|
||||||
if name != dashedname.to_string() {
|
if !is_normalised_element_name(&dashedname.to_string()) {
|
||||||
emit_warning!(
|
emit_warning!(
|
||||||
dashedname.span(),
|
name_span.clone(),
|
||||||
format!(
|
format!(
|
||||||
"The tag '{dashedname}' is not matching its normalized form '{name}'. If you want \
|
"The tag '{dashedname}' is not matching its normalized form '{name}'. If you want \
|
||||||
to keep this form, change this to a dynamic tag `@{{\"{dashedname}\"}}`."
|
to keep this form, change this to a dynamic tag `@{{\"{dashedname}\"}}`."
|
||||||
|
|||||||
@ -35,7 +35,7 @@ fn dynamic_tags_catch_non_ascii() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn html_nested_macro_on_html_element() {
|
fn html_nested_macro_on_html_element() {
|
||||||
let _node = html_nested! {
|
let _node = html_nested! {
|
||||||
<div/>
|
<feBlend/>
|
||||||
};
|
};
|
||||||
let _node = html_nested! {
|
let _node = html_nested! {
|
||||||
<input/>
|
<input/>
|
||||||
|
|||||||
@ -54,7 +54,7 @@ struct NodeWriter<'s> {
|
|||||||
slot: DomSlot,
|
slot: DomSlot,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> NodeWriter<'s> {
|
impl NodeWriter<'_> {
|
||||||
/// Write a new node that has no ancestor
|
/// Write a new node that has no ancestor
|
||||||
fn add(self, node: VNode) -> (Self, BNode) {
|
fn add(self, node: VNode) -> (Self, BNode) {
|
||||||
test_log!("adding: {:?}", node);
|
test_log!("adding: {:?}", node);
|
||||||
|
|||||||
@ -49,7 +49,6 @@ pub(crate) struct Bundle(BNode);
|
|||||||
|
|
||||||
impl Bundle {
|
impl Bundle {
|
||||||
/// Creates a new bundle.
|
/// Creates a new bundle.
|
||||||
|
|
||||||
pub const fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self(BNode::List(BList::new()))
|
Self(BNode::List(BList::new()))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user