Files
dioxus/packages/core/src/root_wrapper.rs
T
Evan AlmloffandJonathan Kelley d41ab3a756 Fix hydration of suspense fragments that contain text nodes (#3287)
* Fix hydration of suspense fragments that contain text nodes

* fix release builds

* disable link deduplication

* restore meta tag deduplication

* Add a test for the failed hydration case

* make changes to the document trait non-breaking

* remove info log from server future hook

* restore default implementation - this was also a breaking change

* fix semver breakage

* clean up server_future

* Cleanup unused code

* fix clippy

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2025-01-07 19:47:23 -08:00

40 lines
1.5 KiB
Rust

use crate::{prelude::*, properties::RootProps, DynamicNode, VComponent};
// We wrap the root scope in a component that renders it inside a default ErrorBoundary and SuspenseBoundary
#[allow(non_snake_case)]
#[allow(clippy::let_and_return)]
pub(crate) fn RootScopeWrapper(props: RootProps<VComponent>) -> Element {
static TEMPLATE: Template = Template {
roots: &[TemplateNode::Dynamic { id: 0usize }],
node_paths: &[&[0u8]],
attr_paths: &[],
};
Element::Ok(VNode::new(
None,
TEMPLATE,
Box::new([DynamicNode::Component(
fc_to_builder(SuspenseBoundary)
.fallback(|_| Element::Ok(VNode::placeholder()))
.children(Ok(VNode::new(
None,
TEMPLATE,
Box::new([DynamicNode::Component({
fc_to_builder(ErrorBoundary)
.children(Element::Ok(VNode::new(
None,
TEMPLATE,
Box::new([DynamicNode::Component(props.0)]),
Box::new([]),
)))
.build()
.into_vcomponent(ErrorBoundary)
})]),
Box::new([]),
)))
.build()
.into_vcomponent(SuspenseBoundary),
)]),
Box::new([]),
))
}