pub struct Node(/* private fields */);
Expand description
A reference to a JavaScript object which implements the INode interface.
Implementations§
Source§impl Node
impl Node
Sourcepub fn from_html(html: &str) -> Result<Node, SyntaxError>
pub fn from_html(html: &str) -> Result<Node, SyntaxError>
Attempt to create the Node
from raw html. The html string must contain exactly one
root node.
Returns a SyntaxError
if:
- There is not exactly one root node.
- The html syntax is wrong. However, on most browsers the html parsing algorighm is unbelievably forgiving and will just turn your html into text or maybe even an empty string.
It is recommended to have control over the html being given to this function as not having control is a security concern.
For more details, see information about setting innerHTML
:
https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
Trait Implementations§
Source§impl From<CanvasElement> for Node
impl From<CanvasElement> for Node
Source§fn from(value: CanvasElement) -> Self
fn from(value: CanvasElement) -> Self
Converts to this type from the input type.
Source§impl From<DocumentFragment> for Node
impl From<DocumentFragment> for Node
Source§fn from(value: DocumentFragment) -> Self
fn from(value: DocumentFragment) -> Self
Converts to this type from the input type.
Source§impl From<HtmlElement> for Node
impl From<HtmlElement> for Node
Source§fn from(value: HtmlElement) -> Self
fn from(value: HtmlElement) -> Self
Converts to this type from the input type.
Source§impl From<ImageElement> for Node
impl From<ImageElement> for Node
Source§fn from(value: ImageElement) -> Self
fn from(value: ImageElement) -> Self
Converts to this type from the input type.
Source§impl From<InputElement> for Node
impl From<InputElement> for Node
Source§fn from(value: InputElement) -> Self
fn from(value: InputElement) -> Self
Converts to this type from the input type.
Source§impl From<Node> for EventTarget
impl From<Node> for EventTarget
Source§impl From<OptionElement> for Node
impl From<OptionElement> for Node
Source§fn from(value: OptionElement) -> Self
fn from(value: OptionElement) -> Self
Converts to this type from the input type.
Source§impl From<SelectElement> for Node
impl From<SelectElement> for Node
Source§fn from(value: SelectElement) -> Self
fn from(value: SelectElement) -> Self
Converts to this type from the input type.
Source§impl From<ShadowRoot> for Node
impl From<ShadowRoot> for Node
Source§fn from(value: ShadowRoot) -> Self
fn from(value: ShadowRoot) -> Self
Converts to this type from the input type.
Source§impl From<SlotElement> for Node
impl From<SlotElement> for Node
Source§fn from(value: SlotElement) -> Self
fn from(value: SlotElement) -> Self
Converts to this type from the input type.
Source§impl From<TemplateElement> for Node
impl From<TemplateElement> for Node
Source§fn from(value: TemplateElement) -> Self
fn from(value: TemplateElement) -> Self
Converts to this type from the input type.
Source§impl From<TextAreaElement> for Node
impl From<TextAreaElement> for Node
Source§fn from(value: TextAreaElement) -> Self
fn from(value: TextAreaElement) -> Self
Converts to this type from the input type.
Source§impl IEventTarget for Node
impl IEventTarget for Node
Source§fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandlewhere
T: ConcreteEvent,
F: FnMut(T) + 'static,
fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandlewhere
T: ConcreteEvent,
F: FnMut(T) + 'static,
Adds given event handler to the list of event listeners for
the specified
EventTarget
on which it’s called. Read moreSource§impl INode for Node
impl INode for Node
Source§fn append_child<T: INode>(&self, child: &T)
fn append_child<T: INode>(&self, child: &T)
Adds a node to the end of the list of children of a specified parent node. Read more
Source§fn remove_child<T: INode>(&self, child: &T) -> Result<Node, NotFoundError>
fn remove_child<T: INode>(&self, child: &T) -> Result<Node, NotFoundError>
Removes a child node from the DOM. Read more
Source§fn clone_node(&self, kind: CloneKind) -> Result<Self, TODO>
fn clone_node(&self, kind: CloneKind) -> Result<Self, TODO>
Returns a duplicate of the node on which this method was called. Read more
Source§fn contains<T: INode>(&self, node: &T) -> bool
fn contains<T: INode>(&self, node: &T) -> bool
Checks whenever a given node is a descendant of this one or not. Read more
Source§fn insert_before<T: INode, U: INode>(
&self,
new_node: &T,
reference_node: &U,
) -> Result<Node, InsertNodeError>
fn insert_before<T: INode, U: INode>( &self, new_node: &T, reference_node: &U, ) -> Result<Node, InsertNodeError>
Inserts the specified node before the reference node as a child of the current node. Read more
Source§fn replace_child<T: INode, U: INode>(
&self,
new_child: &T,
old_child: &U,
) -> Result<Node, InsertNodeError>
fn replace_child<T: INode, U: INode>( &self, new_child: &T, old_child: &U, ) -> Result<Node, InsertNodeError>
Replaces one hild node of the specified node with another. Read more
Source§fn parent_node(&self) -> Option<Node>
fn parent_node(&self) -> Option<Node>
Returns the parent of this node in the DOM tree. Read more
Source§fn first_child(&self) -> Option<Node>
fn first_child(&self) -> Option<Node>
Returns the node’s first child in the tree, or
None
if the node is childless. Read moreSource§fn last_child(&self) -> Option<Node>
fn last_child(&self) -> Option<Node>
Returns the node’s last child in the tree, or
None
if the node is childless. Read moreSource§fn next_sibling(&self) -> Option<Node>
fn next_sibling(&self) -> Option<Node>
Returns the node’s next sibling in the tree, or
None
if there isn’t such a node. Read moreSource§fn owner_document(&self) -> Option<Document>
fn owner_document(&self) -> Option<Document>
Returns the
Document
that this node belongs to. Read moreSource§fn parent_element(&self) -> Option<Element>
fn parent_element(&self) -> Option<Element>
Returns an
Element
that is the parent of this node. Returns null
if the node
has no parent or the parent is not an Element
. Read moreSource§fn previous_sibling(&self) -> Option<Node>
fn previous_sibling(&self) -> Option<Node>
Returns the node’s previous sibling in the tree, or
None
if there isn’t such a node. Read moreSource§fn text_content(&self) -> Option<String>
fn text_content(&self) -> Option<String>
A property which represents the text content of a node and its descendants. Read more
Source§fn set_text_content(&self, text: &str)
fn set_text_content(&self, text: &str)
Sets the text content of this node; calling thil removes all
of node’s children and replaces them with a single text node
with the given value. Read more
Source§fn child_nodes(&self) -> NodeList
fn child_nodes(&self) -> NodeList
Returns a live collection of child nodes of this node. Read more
Source§fn has_child_nodes(&self) -> bool
fn has_child_nodes(&self) -> bool
Returns whether this node has children nodes. Read more
Source§fn is_default_namespace(&self, namespace: &str) -> bool
fn is_default_namespace(&self, namespace: &str) -> bool
Determines whether the given namespace is the default namespace of this node. Read more
Source§fn is_equal_node<T: INode>(&self, node: &T) -> bool
fn is_equal_node<T: INode>(&self, node: &T) -> bool
Tests whether this node is equal to another node. Two nodes are equal if
they have the same type, defining characteristics, matching attributes,
and so on. Read more
Source§fn is_same_node<T: INode>(&self, node: &T) -> bool
fn is_same_node<T: INode>(&self, node: &T) -> bool
Test whether two
Node
references are the same. Read moreSource§fn lookup_prefix(&self, namespace: &str) -> Option<String>
fn lookup_prefix(&self, namespace: &str) -> Option<String>
Returns the prefix for the given namespace URI, if present. Read more
Source§impl InstanceOf for Node
impl InstanceOf for Node
Source§impl ReferenceType for Node
impl ReferenceType for Node
Source§unsafe fn from_reference_unchecked(reference: Reference) -> Self
unsafe fn from_reference_unchecked(reference: Reference) -> Self
Converts a given reference into a concrete reference-like wrapper.
Doesn’t do any type checking; highly unsafe to use!
Source§impl TryFrom<EventTarget> for Node
impl TryFrom<EventTarget> for Node
Source§impl TryFrom<Node> for CanvasElement
impl TryFrom<Node> for CanvasElement
Source§impl TryFrom<Node> for DocumentFragment
impl TryFrom<Node> for DocumentFragment
Source§impl TryFrom<Node> for HtmlElement
impl TryFrom<Node> for HtmlElement
Source§impl TryFrom<Node> for ImageElement
impl TryFrom<Node> for ImageElement
Source§impl TryFrom<Node> for InputElement
impl TryFrom<Node> for InputElement
Source§impl TryFrom<Node> for OptionElement
impl TryFrom<Node> for OptionElement
Source§impl TryFrom<Node> for SelectElement
impl TryFrom<Node> for SelectElement
Source§impl TryFrom<Node> for ShadowRoot
impl TryFrom<Node> for ShadowRoot
Source§impl TryFrom<Node> for SlotElement
impl TryFrom<Node> for SlotElement
Source§impl TryFrom<Node> for TemplateElement
impl TryFrom<Node> for TemplateElement
Source§impl TryFrom<Node> for TextAreaElement
impl TryFrom<Node> for TextAreaElement
impl Eq for Node
impl JsSerialize for Node
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more