Struct sycamore::web::HydrateNode
source · [−]pub struct HydrateNode { /* private fields */ }
Expand description
Rendering backend for the DOM with hydration support.
This API requires the following crate features to be activated: hydrate
, dom
Implementations
sourceimpl HydrateNode
impl HydrateNode
sourcepub fn inner_element(&self) -> Node
pub fn inner_element(&self) -> Node
Get the underlying web_sys::Node
.
sourcepub fn unchecked_into<T>(self) -> Twhere
T: JsCast,
pub fn unchecked_into<T>(self) -> Twhere
T: JsCast,
Cast the underlying web_sys::Node
using JsCast
.
sourcepub fn from_web_sys(node: Node) -> HydrateNode
pub fn from_web_sys(node: Node) -> HydrateNode
Create a new DomNode
from a raw web_sys::Node
.
Trait Implementations
sourceimpl AsRef<JsValue> for HydrateNode
impl AsRef<JsValue> for HydrateNode
sourceimpl Clone for HydrateNode
impl Clone for HydrateNode
sourcefn clone(&self) -> HydrateNode
fn clone(&self) -> HydrateNode
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for HydrateNode
impl Debug for HydrateNode
sourceimpl From<HydrateNode> for JsValue
impl From<HydrateNode> for JsValue
sourcefn from(node: HydrateNode) -> JsValue
fn from(node: HydrateNode) -> JsValue
Converts to this type from the input type.
sourceimpl GenericNode for HydrateNode
impl GenericNode for HydrateNode
sourcefn element<T>() -> HydrateNodewhere
T: SycamoreElement,
fn element<T>() -> HydrateNodewhere
T: SycamoreElement,
When hydrating, instead of creating a new node, this will attempt to hydrate an existing node.
sourcefn element_from_tag(tag: &str) -> HydrateNode
fn element_from_tag(tag: &str) -> HydrateNode
When hydrating, instead of creating a new node, this will attempt to hydrate an existing node.
sourcefn text_node(text: &str) -> HydrateNode
fn text_node(text: &str) -> HydrateNode
When hydrating, instead of creating a new node, this will attempt to hydrate an existing node.
type PropertyType = JsValue
type PropertyType = JsValue
The type for
set_property
.sourceconst USE_HYDRATION_CONTEXT: bool = true
const USE_HYDRATION_CONTEXT: bool = true
Whether this rendering backend needs the hydration registry.
sourceconst CLIENT_SIDE_HYDRATION: bool = true
const CLIENT_SIDE_HYDRATION: bool = true
Whether this rendering backend hydrates nodes on the client side.
sourcefn marker() -> HydrateNode
fn marker() -> HydrateNode
Create a marker (dummy) node. For
DomNode
, this is implemented by creating an empty
comment node. This is used, for example, in Keyed
and Indexed
for scenarios where you
want to push a new item to the end of the list. If the list is empty, a dummy node is
needed to store the position of the component. Read moresourcefn marker_with_text(text: &str) -> HydrateNode
fn marker_with_text(text: &str) -> HydrateNode
Create a marker (dummy) node with text content. For empty marker, prefer
GenericNode::marker
instead. Read moresourcefn set_attribute(&self, name: &str, value: &str)
fn set_attribute(&self, name: &str, value: &str)
Sets an attribute on a node.
sourcefn remove_attribute(&self, name: &str)
fn remove_attribute(&self, name: &str)
Removes an attribute on a node.
sourcefn set_class_name(&self, value: &str)
fn set_class_name(&self, value: &str)
Sets the
class
attribute on a node.
This should have the same outcome as calling set_attribute("class", value)
.
For DomNode
, this sets the className
property directly which is about 2x faster (on
Chrome). Read moresourcefn add_class(&self, class: &str)
fn add_class(&self, class: &str)
Add a class to the element.
If multiple classes are specified, delimited by spaces, all the classes should be added.
Any classes that are already present should not be added a second time. Read more
sourcefn remove_class(&self, class: &str)
fn remove_class(&self, class: &str)
Remove a class from the element.
sourcefn set_property(&self, name: &str, value: &JsValue)
fn set_property(&self, name: &str, value: &JsValue)
Sets a property on a node.
sourcefn remove_property(&self, name: &str)
fn remove_property(&self, name: &str)
Removes a property on a node.
sourcefn append_child(&self, child: &HydrateNode)
fn append_child(&self, child: &HydrateNode)
Appends a child to the node’s children.
sourcefn first_child(&self) -> Option<HydrateNode>
fn first_child(&self) -> Option<HydrateNode>
Get the first child of the node.
sourcefn insert_child_before(
&self,
new_node: &HydrateNode,
reference_node: Option<&HydrateNode>
)
fn insert_child_before(
&self,
new_node: &HydrateNode,
reference_node: Option<&HydrateNode>
)
Insert a new child node to this node’s children. If
reference_node
is Some
, the child
will be inserted before the reference node. Else if None
, the child will be inserted
at the end. Read moresourcefn remove_child(&self, child: &HydrateNode)
fn remove_child(&self, child: &HydrateNode)
Remove a child node from this node’s children.
sourcefn replace_child(&self, old: &HydrateNode, new: &HydrateNode)
fn replace_child(&self, old: &HydrateNode, new: &HydrateNode)
Replace a child node from this node’s children with a new child node.
sourcefn insert_sibling_before(&self, child: &HydrateNode)
fn insert_sibling_before(&self, child: &HydrateNode)
Insert a new node before this node.
sourcefn parent_node(&self) -> Option<HydrateNode>
fn parent_node(&self) -> Option<HydrateNode>
Returns the parent node, or
None
if detached.sourcefn next_sibling(&self) -> Option<HydrateNode>
fn next_sibling(&self) -> Option<HydrateNode>
Returns the next sibling, or
None
if this node is the last sibling.sourcefn remove_self(&self)
fn remove_self(&self)
Remove this node from the tree.
sourcefn event<'a, F>(&self, cx: BoundedScope<'a, 'a>, name: &str, handler: F)where
F: 'a + FnMut(<HydrateNode as GenericNode>::EventType),
fn event<'a, F>(&self, cx: BoundedScope<'a, 'a>, name: &str, handler: F)where
F: 'a + FnMut(<HydrateNode as GenericNode>::EventType),
Add a event handler to the event
name
.
The event should be removed once the scope is disposed, as to prevent accessing scope
variables after the scope is disposed. Read moresourcefn update_inner_text(&self, text: &str)
fn update_inner_text(&self, text: &str)
Update inner text of the node. If the node has elements, all the elements are replaced with
a new text node. Read more
sourcefn dangerously_set_inner_html(&self, html: &str)
fn dangerously_set_inner_html(&self, html: &str)
Updates the inner html of the node.
The html will not be parsed in non-browser environments. This means that accessing methods
such as
first_child
will return None
. Read moresourcefn clone_node(&self) -> HydrateNode
fn clone_node(&self) -> HydrateNode
Create a deep clone of the node.
sourcefn text_node_int(int: i32) -> Self
fn text_node_int(int: i32) -> Self
Create a new text node from an integer.
sourceimpl Hash for HydrateNode
impl Hash for HydrateNode
sourceimpl Html for HydrateNode
impl Html for HydrateNode
sourceconst IS_BROWSER: bool = true
const IS_BROWSER: bool = true
A boolean indicating whether this node is rendered in a browser context. Read more
sourcefn to_web_sys(&self) -> Node
fn to_web_sys(&self) -> Node
Convert this node into a raw
web_sys::Node
. Read moresourceimpl PartialEq<HydrateNode> for HydrateNode
impl PartialEq<HydrateNode> for HydrateNode
sourcefn eq(&self, other: &HydrateNode) -> bool
fn eq(&self, other: &HydrateNode) -> bool
impl Eq for HydrateNode
Auto Trait Implementations
impl !RefUnwindSafe for HydrateNode
impl !Send for HydrateNode
impl !Sync for HydrateNode
impl Unpin for HydrateNode
impl UnwindSafe for HydrateNode
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for Twhere
T: Hash + ?Sized,
impl<T> CallHasher for Twhere
T: Hash + ?Sized,
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.