Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/yew-macro/src/html_tree/html_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,20 @@ impl ToTokens for HtmlElement {
tokens.extend(match &name {
TagName::Lit(dashedname) => {
let name_span = dashedname.span();
let name = dashedname.to_ascii_lowercase_string();
// Always preserve casing from the user's code
let name = dashedname.to_string();
let lowercase_name = dashedname.to_ascii_lowercase_string();
if !is_normalised_element_name(&dashedname.to_string()) {
emit_warning!(
name_span.clone(),
format!(
"The tag '{dashedname}' is not matching its normalized form '{name}'. If you want \
"The tag '{dashedname}' is not matching its normalized form '{lowercase_name}'. If you want \
to keep this form, change this to a dynamic tag `@{{\"{dashedname}\"}}`."
)
)
}
let node = match &*name {
// Use lowercase for compile-time checks but preserve original casing in output
let node = match &*lowercase_name {
"input" => {
let value = value();
let checked = checked();
Expand Down
9 changes: 6 additions & 3 deletions packages/yew/src/virtual_dom/vtag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,13 @@ impl VTag {
/// Creates a new [VTag] instance with `tag` name (cannot be changed later in DOM).
pub fn new(tag: impl Into<AttrValue>) -> Self {
let tag = tag.into();
let lowercase_tag = tag.to_ascii_lowercase();
Self::new_base(
match &*tag.to_ascii_lowercase() {
match &*lowercase_tag {
"input" => VTagInner::Input(Default::default()),
"textarea" => VTagInner::Textarea(Default::default()),
_ => VTagInner::Other {
tag,
tag, // Preserve the original casing
children: Default::default(),
},
},
Expand Down Expand Up @@ -537,7 +538,9 @@ mod feat_ssr {
let _ = w.write_str("</textarea>");
}
VTagInner::Other { tag, children } => {
if !VOID_ELEMENTS.contains(&tag.as_ref()) {
// Check if it's a void element using case-insensitive comparison
let lowercase_tag = tag.to_ascii_lowercase();
if !VOID_ELEMENTS.contains(&lowercase_tag.as_ref()) {
children
.render_into_stream(w, parent_scope, hydratable, tag.into())
.await;
Expand Down
Loading