Open Defernus opened 1 month ago
I don't think it's possible to change these function signatures in a way that isn't technically a breaking change, although I may be wrong. I do know that they will change significantly in the next release as part of the wider renderer rewrite, so I will mark this issue as 0.7 to make sure there's a decent solution then.
0.7 does support spreading arbitrary attributes of any kind onto any component, which seems to me like it should help.
Also, I don't see any reason why the Binding::Attribute name is &'static str instead of Oco<'static, str>. Because of this, I can't do the following:
use leptos::*;
#[component]
pub fn MyComponent(
#[prop(attrs, optional)] attrs: Vec<(Oco<'static, str>, Attribute)>,
) -> impl IntoView {
view! { <span {..attrs}></span> }
}
Describe the bug The
leptos_dom::html::HtmlElement::attrs
method does not acceptVec<(Oco<'static, str>, Attribute)>
.However, it will accept
Vec<(&'static str, Attribute)>
and will convertname
toOco<'static, str>
in theHtmlElement::attr
method.The same issue occurs with
leptos::DynAttrs::dyn_attrs
, which will only acceptVec<(&'static str, Attribute)>
.Leptos Dependencies
To Reproduce
Expected behavior
The method should accept
Vec<(Oco<'static, str>, Attribute)>
as a type for dynamic attributes.Additional context
I am working on Storybook integration for Leptos and parsing props for components from
JsValue
. Currently, it is impossible to use regular arguments, so I have to do something like this: