Fix input dynamic text rendered as textarea (#3239) (#3301)

This commit is contained in:
Xu Shaohua 2023-08-05 21:58:19 +08:00 committed by GitHub
parent d803df9336
commit a9ab085e74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -428,8 +428,9 @@ impl ToTokens for HtmlElement {
#[allow(clippy::redundant_clone, unused_braces, clippy::let_and_return)]
let mut #vtag = match () {
_ if "input".eq_ignore_ascii_case(::std::convert::AsRef::<::std::primitive::str>::as_ref(&#vtag_name)) => {
::yew::virtual_dom::VTag::__new_textarea(
::yew::virtual_dom::VTag::__new_input(
#value,
#checked,
#node_ref,
#key,
#attributes,
@ -465,7 +466,8 @@ impl ToTokens for HtmlElement {
// For literal tags this is already done at compile-time.
//
// check void element
if !::std::matches!(
if ::yew::virtual_dom::VTag::children(&#vtag).is_some() &&
!::std::matches!(
::yew::virtual_dom::VTag::children(&#vtag),
::std::option::Option::Some(::yew::virtual_dom::VNode::VList(ref #void_children)) if ::std::vec::Vec::is_empty(#void_children)
) {

View File

@ -60,4 +60,10 @@ fn main() {
}
}/>
};
let input_tag = "input";
let input_dom = ::yew::html! { <@{input_tag} /> };
assert!(
::std::matches!(input_dom, ::yew::virtual_dom::VNode::VTag(ref vtag) if vtag.tag() == "input")
);
}