@@ -7,7 +7,7 @@ pub use implicit_clone::ImplicitClone;
77use super :: ToHtml ;
88use crate :: callback:: Callback ;
99use crate :: html:: { BaseComponent , ChildrenRenderer , Component , NodeRef , Scope } ;
10- use crate :: virtual_dom:: { AttrValue , VChild , VNode , VText } ;
10+ use crate :: virtual_dom:: { AttrValue , VChild , VList , VNode , VText } ;
1111
1212impl ImplicitClone for NodeRef { }
1313impl < Comp : Component > ImplicitClone for Scope < Comp > { }
@@ -154,6 +154,20 @@ impl IntoPropValue<ChildrenRenderer<VNode>> for VText {
154154 }
155155}
156156
157+ impl IntoPropValue < VList > for ChildrenRenderer < VNode > {
158+ #[ inline]
159+ fn into_prop_value ( self ) -> VList {
160+ VList :: with_children ( self . children , None )
161+ }
162+ }
163+
164+ impl < C : BaseComponent > IntoPropValue < VList > for VChild < C > {
165+ #[ inline]
166+ fn into_prop_value ( self ) -> VList {
167+ VList :: with_children ( vec ! [ self . into( ) ] , None )
168+ }
169+ }
170+
157171macro_rules! impl_into_prop {
158172 ( |$value: ident: $from_ty: ty| -> $to_ty: ty { $conversion: expr } ) => {
159173 // implement V -> T
@@ -341,4 +355,57 @@ mod test {
341355 </App >
342356 } ;
343357 }
358+
359+ #[ test]
360+ fn test_vlist_to_children_compiles ( ) {
361+ use crate :: prelude:: * ;
362+ use crate :: virtual_dom:: VList ;
363+
364+ #[ function_component]
365+ fn Foo ( ) -> Html {
366+ todo ! ( )
367+ }
368+
369+ #[ derive( PartialEq , Properties ) ]
370+ pub struct ChildProps {
371+ #[ prop_or_default]
372+ pub children : Html ,
373+ }
374+
375+ #[ function_component]
376+ fn Child ( _props : & ChildProps ) -> Html {
377+ html ! ( )
378+ }
379+
380+ #[ derive( PartialEq , Properties ) ]
381+ pub struct ParentProps {
382+ pub children : VList ,
383+ }
384+
385+ #[ function_component]
386+ fn Parent ( _props : & ParentProps ) -> Html {
387+ todo ! ( )
388+ }
389+
390+ let _ = html ! {
391+ <Parent >
392+ <Child ></Child >
393+ </Parent >
394+ } ;
395+
396+ let _ = html ! {
397+ <Parent >
398+ <Child />
399+ <Child />
400+ </Parent >
401+ } ;
402+
403+ let _ = html ! {
404+ <Parent >
405+ <Child >
406+ <Foo />
407+ </Child >
408+ </Parent >
409+ } ;
410+ }
344411}
0 commit comments