Skip to content

Commit

Permalink
xilem_html: Implement DOM interface traits for Adapt and AdaptState
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp-M committed Nov 8, 2023
1 parent 4e1fbce commit 5b8bb96
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions crates/xilem_html/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ macro_rules! dom_interface_macro_and_trait_definitions {
child_interfaces: {$($interface $interface_body,)*}
}
);
macro_rules! for_all_dom_interfaces {
($mac:path, $extra_params:tt) => {
$mac!(Element, $extra_params);
$crate::interfaces::for_all_element_descendents!($mac, $extra_params);
};
}
pub(crate) use for_all_dom_interfaces;
}
}

Expand Down Expand Up @@ -409,3 +416,34 @@ dom_interface_macro_and_trait_definitions!(
child_interfaces: {}
},
);

// Core View implementations

impl<ParentT, ParentA, ChildT, ChildA, V, F> sealed::Sealed
for crate::Adapt<ParentT, ParentA, ChildT, ChildA, V, F>
{
}
impl<ParentT, ChildT, V, F> sealed::Sealed for crate::AdaptState<ParentT, ChildT, V, F> {}

macro_rules! impl_dom_traits_for_adapt_views {
($dom_interface:ident, ()) => {
impl<ParentT, ParentA, ChildT, ChildA, V, F> $dom_interface<ParentT, ParentA>
for crate::Adapt<ParentT, ParentA, ChildT, ChildA, V, F>
where
V: $dom_interface<ChildT, ChildA>,
F: Fn(
&mut ParentT,
crate::AdaptThunk<ChildT, ChildA, V>,
) -> xilem_core::MessageResult<ParentA>,
{
}
impl<ParentT, ChildT, A, V, F> $dom_interface<ParentT, A>
for crate::AdaptState<ParentT, ChildT, V, F>
where
V: $dom_interface<ChildT, A>,
F: Fn(&mut ParentT) -> &mut ChildT,
{
}
};
}
for_all_dom_interfaces!(impl_dom_traits_for_adapt_views, ());

0 comments on commit 5b8bb96

Please sign in to comment.