pub struct AttrValueAdapter<T> { /* private fields */ }Expand description
Adapts an arbitrary attribute value expression into an AttributeValue.
Handles the dispatch between event closures and reactive values without
requiring the macro to generate inline trait hierarchies. The macro emits
AttrValueAdapter::new(expr).into_attribute_value() instead of the
__IsClosure / __ClosurePicker / __ValuePicker / __FallbackHelper
/ __dispatch boilerplate.
For event attributes (key starts with “on”), event closures are wrapped
into AttributeValue::Event. For non-event attributes, values are
converted via IntoReactiveValue.
Implementations§
Source§impl<T> AttrValueAdapter<T>
Constructs an AttrValueAdapter that wraps any attribute-compatible value.
impl<T> AttrValueAdapter<T>
Constructs an AttrValueAdapter that wraps any attribute-compatible value.
Source§impl<F> AttrValueAdapter<F>where
F: FnMut(NativeEvent) + 'static,
Adapts a FnMut(NativeEvent) closure into a callback AttributeValue.
impl<F> AttrValueAdapter<F>where
F: FnMut(NativeEvent) + 'static,
Adapts a FnMut(NativeEvent) closure into a callback AttributeValue.
This handles the case where a closure is used as a component callback prop.
The closure is converted via IntoCallbackAttribute::into_callback_attribute().
This replaces the __IsClosure for F impl that was previously generated inline.
Sourcepub fn into_callback_attribute_value(self) -> AttributeValue
pub fn into_callback_attribute_value(self) -> AttributeValue
Converts the wrapped closure into a callback AttributeValue.
§Returns
AttributeValue- An event attribute value wrapping the adapted closure.
Sourcepub fn into_callback_attribute_value_with_name(
self,
name: String,
) -> AttributeValue
pub fn into_callback_attribute_value_with_name( self, name: String, ) -> AttributeValue
Source§impl AttrValueAdapter<NativeEventHandler>
Adapts an owned NativeEventHandler into an AttributeValue::Event directly.
impl AttrValueAdapter<NativeEventHandler>
Adapts an owned NativeEventHandler into an AttributeValue::Event directly.
When the user already provides a NativeEventHandler, the handler is
re-wrapped with a generic “callback” event name so that subsequent
EventAdapter::into_attribute calls can override it with the correct
DOM event type. This replaces the __IsClosure for NativeEventHandler
impl that was previously generated inline by the html! macro.
Sourcepub fn into_callback_attribute_value(self) -> AttributeValue
pub fn into_callback_attribute_value(self) -> AttributeValue
Converts the wrapped handler into an event AttributeValue.
Re-wraps the handler with a generic callback event name so that the
DOM event type can be correctly resolved when the handler is later
bound to a real element via EventAdapter::into_attribute.
§Returns
AttributeValue- AnAttributeValue::Eventcontaining the re-wrapped handler.
Sourcepub fn into_callback_attribute_value_with_name(
self,
name: String,
) -> AttributeValue
pub fn into_callback_attribute_value_with_name( self, name: String, ) -> AttributeValue
Source§impl AttrValueAdapter<Option<NativeEventHandler>>
Adapts an Option<NativeEventHandler> into an AttributeValue.
impl AttrValueAdapter<Option<NativeEventHandler>>
Adapts an Option<NativeEventHandler> into an AttributeValue.
Some(handler) becomes AttributeValue::Event(handler) re-wrapped with
a generic callback event name, and None becomes AttributeValue::Text(String::new()).
This replaces the __IsClosure for Option<NativeEventHandler> impl that was
previously generated inline by the html! macro.
Sourcepub fn into_callback_attribute_value(self) -> AttributeValue
pub fn into_callback_attribute_value(self) -> AttributeValue
Converts the wrapped optional handler into an attribute value.
Re-wraps a Some handler with a generic callback event name so that the
DOM event type can be correctly resolved when the handler is later bound
to a real element via EventAdapter::into_attribute.
§Returns
AttributeValue- An event attribute ifSome, otherwise an empty text attribute.
Sourcepub fn into_callback_attribute_value_with_name(
self,
name: String,
) -> AttributeValue
pub fn into_callback_attribute_value_with_name( self, name: String, ) -> AttributeValue
Source§impl<T> AttrValueAdapter<T>where
T: IntoReactiveValue,
Adapts any IntoReactiveValue type into an AttributeValue.
impl<T> AttrValueAdapter<T>where
T: IntoReactiveValue,
Adapts any IntoReactiveValue type into an AttributeValue.
This is the fallback path for non-closure attribute values (strings, signals,
CSS classes, etc.). The value is converted via IntoReactiveValue::into_reactive_value().
This replaces the __ValuePicker / __FallbackHelper hierarchy that was previously
generated inline by the html! macro.
Sourcepub fn into_reactive_attribute_value(self) -> AttributeValue
pub fn into_reactive_attribute_value(self) -> AttributeValue
Converts the wrapped value into an AttributeValue via reactive value adaptation.
§Returns
AttributeValue- The reactive attribute value.