implement html from Option<VNode> (#2792)

Co-authored-by: Martin Molzer <WorldSEnder@users.noreply.github.com>
This commit is contained in:
Cecile Tonglet 2022-09-14 15:04:12 +02:00 committed by GitHub
parent 8eb9b5a4dc
commit 81f7ea482b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -121,6 +121,9 @@ fn compile_pass() {
// test for https://github.com/yewstack/yew/issues/2810
::yew::html! { <div data-type="date" data-as="calender" /> };
let option_vnode = ::std::option::Option::Some(::yew::html! {});
::yew::html! { <div>{option_vnode}</div> };
}
fn main() {}

View File

@ -23,6 +23,15 @@ impl<IN: Into<OUT>, OUT> From<IN> for NodeSeq<IN, OUT> {
}
}
impl<IN: Into<OUT>, OUT> From<Option<IN>> for NodeSeq<IN, OUT> {
fn from(val: Option<IN>) -> Self {
Self(
val.map(|s| vec![s.into()]).unwrap_or_default(),
PhantomData::default(),
)
}
}
impl<IN: Into<OUT>, OUT> From<Vec<IN>> for NodeSeq<IN, OUT> {
fn from(val: Vec<IN>) -> Self {
Self(