Skip to content

Commit

Permalink
Temporary "fake" hydration (#101)
Browse files Browse the repository at this point in the history
* Fix docs for SsrNode

* Add comments about hydrate
  • Loading branch information
lukechu10 authored Jun 25, 2021
1 parent db69e72 commit ffc1f45
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion packages/sycamore/src/easing.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Easing functions.
use core::f32;
use std::f32::consts::PI;

const EXP_BASE: f32 = 2.0;
Expand Down
6 changes: 6 additions & 0 deletions packages/sycamore/src/generic_node/dom_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ pub fn render_to(template: impl FnOnce() -> Template<DomNode>, 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<DomNode>) {
let window = web_sys::window().unwrap();
Expand Down Expand Up @@ -281,6 +284,9 @@ fn get_children(parent: &Element) -> Vec<Element> {
///
/// 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<DomNode>, parent: &Node) {
for child in get_children(parent.unchecked_ref()) {
Expand Down
7 changes: 4 additions & 3 deletions packages/sycamore/src/generic_node/ssr_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Element>),
Expand All @@ -34,6 +32,9 @@ struct SsrNodeInner {
parent: RefCell<Weak<SsrNodeInner>>,
}

/// 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<SsrNodeInner>);

Expand Down

0 comments on commit ffc1f45

Please sign in to comment.