feat: props spread

This commit is contained in:
Koji AGAWA committed 2023-08-13 16:45:17 +09:00
1 parent 1ab5a03aef
commit d573f5dfd5
14 files changed
+301 -4

No files matched your search

+2 -2
View File
@@ -73,8 +73,8 @@ pub(crate) mod innerlude {
}
pub use crate::innerlude::{
fc_to_builder, vdom_is_rendering, AnyValue, Attribute, AttributeValue, BorrowedAttributeValue,
CapturedError, Component, DynamicNode, Element, ElementId, Event, Fragment, IntoDynNode,
fc_to_builder, vdom_is_rendering, AnyValue, Attribute, AttributeBox, AttributeValue, BorrowedAttributeValue,
CapturedError, Component, DynamicNode, Element, ElementId, Event, Fragment, HasAttributesBox, IntoDynNode,
LazyNodes, Mutation, Mutations, Properties, RenderReturn, Scope, ScopeId, ScopeState, Scoped,
TaskId, Template, TemplateAttribute, TemplateNode, VComponent, VNode, VPlaceholder, VText,
VirtualDom,
+31
View File
@@ -832,3 +832,34 @@ impl<'a, T: IntoAttributeValue<'a>> IntoAttributeValue<'a> for Option<T> {
}
}
}
pub struct AttributeBox<'a> {
/// The name of the attribute.
pub name: &'a str,
/// The value of the attribute
pub value: Box<dyn IntoAttributeValue<'a> + 'static>,
/// The namespace of the attribute.
///
/// Doesn’t exist in the html spec. Used in Dioxus to denote “style” tags and other attribute groups.
pub namespace: Option<&'static str>,
/// An indication of we should always try and set the attribute. Used in controlled components to ensure changes are propagated
pub volatile: bool,
}
impl<'a> AttributeBox<'a> {
pub fn new(name: &'a str, value: impl IntoAttributeValue<'a> + 'static, namespace: Option<&'static str>, volatile: bool) -> Self {
Self {
name,
value: Box::new(value),
namespace,
volatile,
}
}
}
pub trait HasAttributesBox<'a, T> {
fn push_attribute(self, attr: AttributeBox<'a>) -> T;
}