diff --git a/packages/yew-macro/src/props/component.rs b/packages/yew-macro/src/props/component.rs index f8bade77f..2ca7c8c8c 100644 --- a/packages/yew-macro/src/props/component.rs +++ b/packages/yew-macro/src/props/component.rs @@ -6,7 +6,7 @@ use syn::{ parse::{Parse, ParseStream}, spanned::Spanned, token::Dot2, - Expr, ExprLit, Lit, + Expr, }; struct BaseExpr { @@ -110,15 +110,8 @@ impl ComponentProps { Some(expr) => { let ident = Ident::new("__yew_props", props_ty.span()); let set_props = self.props.iter().map(|Prop { label, value, .. }| { - if is_string_literal(value) { - // String literals should be implicitly converted into `String` - quote_spanned! {value.span()=> - #ident.#label = ::std::convert::Into::into(#value); - } - } else { - quote_spanned! {value.span()=> - #ident.#label = #value; - } + quote_spanned! {value.span()=> + #ident.#label = ::yew::html::IntoPropValue::into_prop_value(#value); } }); let set_children = children_renderer.map(|children| { @@ -145,16 +138,6 @@ impl ComponentProps { } } -fn is_string_literal(expr: &Expr) -> bool { - matches!( - expr, - Expr::Lit(ExprLit { - lit: Lit::Str(_), - .. - }) - ) -} - impl Parse for ComponentProps { fn parse(input: ParseStream) -> syn::Result { let props = validate(input.parse()?)?; diff --git a/packages/yew-macro/tests/html_macro/component-pass.rs b/packages/yew-macro/tests/html_macro/component-pass.rs index f6dbe3c53..8caa8be6e 100644 --- a/packages/yew-macro/tests/html_macro/component-pass.rs +++ b/packages/yew-macro/tests/html_macro/component-pass.rs @@ -246,6 +246,15 @@ fn compile_pass() {
{ "hello world" }
+ + + + + + + + +