fix mounted information

This commit is contained in:
Evan Almloff committed 2024-01-09 11:35:55 -06:00
1 parent 967c082085
commit b43dfb1f67
6 files changed
+44 -35

No files matched your search

+12 -4
View File
@@ -20,8 +20,7 @@ pub type TemplateId = &'static str;
///
/// Dioxus will do its best to immediately resolve any async components into a regular Element, but as an implementor
/// you might need to handle the case where there's no node immediately ready.
#[derive(Clone)]
pub enum RenderReturn {
pub(crate) enum RenderReturn {
/// A currently-available element
Ready(VNode),
@@ -31,6 +30,15 @@ pub enum RenderReturn {
Aborted(VNode),
}
impl Clone for RenderReturn {
fn clone(&self) -> Self {
match self {
RenderReturn::Ready(node) => RenderReturn::Ready(node.clone_mounted()),
RenderReturn::Aborted(node) => RenderReturn::Aborted(node.clone_mounted()),
}
}
}
impl Default for RenderReturn {
fn default() -> Self {
RenderReturn::Aborted(VNode::placeholder())
@@ -125,8 +133,8 @@ impl Deref for VNode {
}
impl VNode {
/// Clone the element while retaining the mounted parent of the node
pub(crate) fn clone_with_parent(&self) -> Self {
/// Clone the element while retaining the mount information of the node
pub(crate) fn clone_mounted(&self) -> Self {
Self {
vnode: self.vnode.clone(),
mount: self.mount.clone(),