From ffc1f4561d3c0e20e1a0a9b655d26f47f5aef4bf Mon Sep 17 00:00:00 2001 From: Luke Chu <37006668+lukechu10@users.noreply.github.com> Date: Fri, 25 Jun 2021 10:41:01 -0700 Subject: [PATCH] Temporary "fake" hydration (#101) * Fix docs for SsrNode * Add comments about hydrate --- packages/sycamore/src/easing.rs | 1 - packages/sycamore/src/generic_node/dom_node.rs | 6 ++++++ packages/sycamore/src/generic_node/ssr_node.rs | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/sycamore/src/easing.rs b/packages/sycamore/src/easing.rs index b6affac81..f0ddde2b5 100644 --- a/packages/sycamore/src/easing.rs +++ b/packages/sycamore/src/easing.rs @@ -1,6 +1,5 @@ //! Easing functions. -use core::f32; use std::f32::consts::PI; const EXP_BASE: f32 = 2.0; diff --git a/packages/sycamore/src/generic_node/dom_node.rs b/packages/sycamore/src/generic_node/dom_node.rs index 0c8b58a95..89552613f 100644 --- a/packages/sycamore/src/generic_node/dom_node.rs +++ b/packages/sycamore/src/generic_node/dom_node.rs @@ -252,6 +252,9 @@ pub fn render_to(template: impl FnOnce() -> Template, parent: &Node) { /// /// For rendering without hydration, use [`render`] instead. /// +/// **TODO**: This method currently deletes existing nodes from DOM and reinserts new +/// created nodes. This will be fixed in a later release. +/// /// _This API requires the following crate features to be activated: `dom`_ pub fn hydrate(template: impl FnOnce() -> Template) { let window = web_sys::window().unwrap(); @@ -281,6 +284,9 @@ fn get_children(parent: &Element) -> Vec { /// /// For rendering without hydration, use [`render`] instead. /// +/// **TODO**: This method currently deletes existing nodes from DOM and reinserts new +/// created nodes. This will be fixed in a later release. +/// /// _This API requires the following crate features to be activated: `dom`_ pub fn hydrate_to(template: impl FnOnce() -> Template, parent: &Node) { for child in get_children(parent.unchecked_ref()) { diff --git a/packages/sycamore/src/generic_node/ssr_node.rs b/packages/sycamore/src/generic_node/ssr_node.rs index d73ddaf2f..ccc5c8533 100644 --- a/packages/sycamore/src/generic_node/ssr_node.rs +++ b/packages/sycamore/src/generic_node/ssr_node.rs @@ -17,9 +17,7 @@ static VOID_ELEMENTS: &[&str] = &[ "track", "wbr", "command", "keygen", "menuitem", ]; -/// Rendering backend for Server Side Rendering, aka. SSR. -/// -/// _This API requires the following crate features to be activated: `ssr`_ +/// Inner representation for [`SsrNode`]. #[derive(Debug)] enum SsrNodeType { Element(RefCell), @@ -34,6 +32,9 @@ struct SsrNodeInner { parent: RefCell>, } +/// Rendering backend for Server Side Rendering, aka. SSR. +/// +/// _This API requires the following crate features to be activated: `ssr`_ #[derive(Debug, Clone)] pub struct SsrNode(Rc);