diff --git a/packages/yew-macro/src/html_tree/html_element.rs b/packages/yew-macro/src/html_tree/html_element.rs index 0124dd0c0d7..b1b0ab2a795 100644 --- a/packages/yew-macro/src/html_tree/html_element.rs +++ b/packages/yew-macro/src/html_tree/html_element.rs @@ -330,7 +330,6 @@ impl ToTokens for HtmlElement { let node = match &*name { "input" => { quote! { - ::std::convert::Into::<::yew::virtual_dom::VNode>::into( ::yew::virtual_dom::VTag::__new_input( #value, #checked, @@ -338,26 +337,22 @@ impl ToTokens for HtmlElement { #key, #attributes, #listeners, - ), ) } } "textarea" => { quote! { - ::std::convert::Into::<::yew::virtual_dom::VNode>::into( ::yew::virtual_dom::VTag::__new_textarea( #value, #node_ref, #key, #attributes, #listeners, - ), ) } } _ => { quote! { - ::std::convert::Into::<::yew::virtual_dom::VNode>::into( ::yew::virtual_dom::VTag::__new_other( ::std::borrow::Cow::<'static, ::std::primitive::str>::Borrowed(#name), #node_ref, @@ -365,7 +360,6 @@ impl ToTokens for HtmlElement { #attributes, #listeners, #children, - ), ) } } diff --git a/packages/yew-macro/src/html_tree/html_list.rs b/packages/yew-macro/src/html_tree/html_list.rs index e48f250bfde..961acc27a53 100644 --- a/packages/yew-macro/src/html_tree/html_list.rs +++ b/packages/yew-macro/src/html_tree/html_list.rs @@ -78,9 +78,7 @@ impl ToTokens for HtmlList { }; tokens.extend(quote_spanned! {spanned.span()=> - ::yew::virtual_dom::VNode::VList( - ::yew::virtual_dom::VList::with_children(#children, #key) - ) + ::yew::virtual_dom::VList::with_children(#children, #key) }); } } diff --git a/packages/yew-macro/src/html_tree/mod.rs b/packages/yew-macro/src/html_tree/mod.rs index 0361231b6d4..67c74349118 100644 --- a/packages/yew-macro/src/html_tree/mod.rs +++ b/packages/yew-macro/src/html_tree/mod.rs @@ -122,8 +122,9 @@ impl ToTokens for HtmlTree { fn to_tokens(&self, tokens: &mut TokenStream) { lint::lint_all(self); match self { + // this is consistent with VNode::default() HtmlTree::Empty => tokens.extend(quote! { - ::yew::virtual_dom::VNode::VList(::yew::virtual_dom::VList::new()) + ::yew::virtual_dom::VList::new() }), HtmlTree::Component(comp) => comp.to_tokens(tokens), HtmlTree::Element(tag) => tag.to_tokens(tokens), @@ -375,9 +376,7 @@ impl ToTokens for HtmlRootBraced { tokens.extend(quote_spanned! {brace.span.span()=> { - ::yew::virtual_dom::VNode::VList( - ::yew::virtual_dom::VList::with_children(#children, ::std::option::Option::None) - ) + ::yew::virtual_dom::VList::with_children(#children, ::std::option::Option::None) } }); } diff --git a/packages/yew/src/virtual_dom/vnode.rs b/packages/yew/src/virtual_dom/vnode.rs index 943081c2f3e..3ada174cb70 100644 --- a/packages/yew/src/virtual_dom/vnode.rs +++ b/packages/yew/src/virtual_dom/vnode.rs @@ -257,3 +257,35 @@ mod feat_ssr { } } } + +#[cfg(test)] +mod tests { + use super::*; + use crate::{function_component, html_nested, Html}; + + #[function_component] + fn Comp() -> Html { + todo!() + } + + #[test] + fn html_nested_types() { + let _vlist: VList = html_nested! { + <> +