Skip to content

Commit

Permalink
Fix input dynamic text rendered as textarea (#3239) (#3301)
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua authored Aug 5, 2023
1 parent d803df9 commit a9ab085
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/yew-macro/src/html_tree/html_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
) {
Expand Down
6 changes: 6 additions & 0 deletions packages/yew-macro/tests/html_macro/dyn-element-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
);
}

0 comments on commit a9ab085

Please sign in to comment.