fix hydration
This commit is contained in:
1 parent
d17a04931b
commit
940108f242
6 files changed
+83
-36
No files matched your search
@@ -75,8 +75,8 @@ pub use crate::innerlude::{
|
||||
fc_to_builder, generation, schedule_update, schedule_update_any, use_hook, vdom_is_rendering,
|
||||
AnyValue, Attribute, AttributeValue, CapturedError, Component, DynamicNode, Element, ElementId,
|
||||
Event, Fragment, HasAttributes, IntoDynNode, Mutation, Mutations, NoOpMutations, Properties,
|
||||
RenderReturn, ScopeId, Task, Template, TemplateAttribute, TemplateNode, VComponent, VNode,
|
||||
VNodeInner, VPlaceholder, VText, VirtualDom, WriteMutations,
|
||||
RenderReturn, ScopeId, ScopeState, Task, Template, TemplateAttribute, TemplateNode, VComponent,
|
||||
VNode, VNodeInner, VPlaceholder, VText, VirtualDom, WriteMutations,
|
||||
};
|
||||
|
||||
/// The purpose of this module is to alleviate imports of many common types
|
||||
@@ -89,7 +89,7 @@ pub mod prelude {
|
||||
push_future, remove_future, schedule_update, schedule_update_any, spawn, spawn_forever,
|
||||
suspend, use_error_boundary, use_hook, AnyValue, Attribute, Component, Element,
|
||||
ErrorBoundary, Event, EventHandler, Fragment, HasAttributes, IntoAttributeValue,
|
||||
IntoDynNode, Properties, Runtime, RuntimeGuard, ScopeId, Task, Template, TemplateAttribute,
|
||||
TemplateNode, Throw, VNode, VNodeInner, VirtualDom,
|
||||
IntoDynNode, Properties, Runtime, RuntimeGuard, ScopeId, ScopeState, Task, Template,
|
||||
TemplateAttribute, TemplateNode, Throw, VNode, VNodeInner, VirtualDom,
|
||||
};
|
||||
}
|
||||
@@ -234,6 +234,47 @@ impl VNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the mounted id for a dynamic node index
|
||||
pub fn mounted_dynamic_node(
|
||||
&self,
|
||||
dynamic_node_idx: usize,
|
||||
dom: &VirtualDom,
|
||||
) -> Option<ElementId> {
|
||||
let mount = self.mount.get().as_usize()?;
|
||||
|
||||
match &self.dynamic_nodes[dynamic_node_idx] {
|
||||
DynamicNode::Text(_) | DynamicNode::Placeholder(_) => dom
|
||||
.mounts
|
||||
.get(mount)?
|
||||
.mounted_dynamic_nodes
|
||||
.get(dynamic_node_idx)
|
||||
.map(|id| ElementId(*id)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the mounted id for a root node index
|
||||
pub fn mounted_root(&self, root_idx: usize, dom: &VirtualDom) -> Option<ElementId> {
|
||||
let mount = self.mount.get().as_usize()?;
|
||||
|
||||
dom.mounts.get(mount)?.root_ids.get(root_idx).copied()
|
||||
}
|
||||
|
||||
/// Get the mounted id for a dynamic attribute index
|
||||
pub fn mounted_dynamic_attribute(
|
||||
&self,
|
||||
dynamic_attribute_idx: usize,
|
||||
dom: &VirtualDom,
|
||||
) -> Option<ElementId> {
|
||||
let mount = self.mount.get().as_usize()?;
|
||||
|
||||
dom.mounts
|
||||
.get(mount)?
|
||||
.mounted_attributes
|
||||
.get(dynamic_attribute_idx)
|
||||
.copied()
|
||||
}
|
||||
}
|
||||
|
||||
/// A static layout of a UI tree that describes a set of dynamic and static nodes.
|
||||
|
||||
@@ -147,13 +147,13 @@ impl Runtime {
|
||||
/// render! { div {} }
|
||||
/// }
|
||||
/// ```
|
||||
pub struct RuntimeGuard(Rc<Runtime>);
|
||||
pub struct RuntimeGuard(());
|
||||
|
||||
impl RuntimeGuard {
|
||||
/// Create a new runtime guard that sets the current Dioxus runtime. The runtime will be reset when the guard is dropped
|
||||
pub fn new(runtime: Rc<Runtime>) -> Self {
|
||||
push_runtime(runtime.clone());
|
||||
Self(runtime)
|
||||
push_runtime(runtime);
|
||||
Self(())
|
||||
}
|
||||
|
||||
/// Run a function with a given runtime and scope in context
|
||||
|
||||
Reference in new issue
Block a user