pub struct SlotElement(/* private fields */);
Expand description
The HTML <slot>
element represents a placeholder inside a web component that
you can fill with your own markup, which lets you create separate DOM trees and
present them together.
Implementations§
Source§impl SlotElement
impl SlotElement
Sourcepub fn assigned_nodes(&self, kind: SlotContentKind) -> Vec<Node>
pub fn assigned_nodes(&self, kind: SlotContentKind) -> Vec<Node>
Returns slot’s assigned nodes.
Sourcepub fn assigned_elements(&self, kind: SlotContentKind) -> Vec<Element>
pub fn assigned_elements(&self, kind: SlotContentKind) -> Vec<Element>
Similar to assigned_nodes() but limited result to only elements.
Trait Implementations§
Source§impl AsRef<Reference> for SlotElement
impl AsRef<Reference> for SlotElement
Source§impl Clone for SlotElement
impl Clone for SlotElement
Source§fn clone(&self) -> SlotElement
fn clone(&self) -> SlotElement
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SlotElement
impl Debug for SlotElement
Source§impl From<SlotElement> for Element
impl From<SlotElement> for Element
Source§fn from(value: SlotElement) -> Self
fn from(value: SlotElement) -> Self
Converts to this type from the input type.
Source§impl From<SlotElement> for EventTarget
impl From<SlotElement> for EventTarget
Source§fn from(value: SlotElement) -> Self
fn from(value: SlotElement) -> Self
Converts to this type from the input type.
Source§impl From<SlotElement> for HtmlElement
impl From<SlotElement> for HtmlElement
Source§fn from(value: SlotElement) -> Self
fn from(value: SlotElement) -> 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<SlotElement> for Reference
impl From<SlotElement> for Reference
Source§fn from(value: SlotElement) -> Self
fn from(value: SlotElement) -> Self
Converts to this type from the input type.
Source§impl IElement for SlotElement
impl IElement for SlotElement
Source§fn namespace_uri(&self) -> Option<String>
fn namespace_uri(&self) -> Option<String>
The Element.namespaceURI read-only property returns the namespace URI
of the element, or null if the element is not in a namespace. Read more
Source§fn class_list(&self) -> TokenList
fn class_list(&self) -> TokenList
Source§fn has_attribute(&self, name: &str) -> bool
fn has_attribute(&self, name: &str) -> bool
The Element.hasAttribute() method returns a Boolean value indicating whether
the specified element has the specified attribute or not. Read more
Source§fn get_attribute(&self, name: &str) -> Option<String>
fn get_attribute(&self, name: &str) -> Option<String>
Element.getAttribute() returns the value of a specified attribute on the element.
If the given attribute does not exist, the value returned will either be
null or “” (the empty string); Read more
Source§fn set_attribute(
&self,
name: &str,
value: &str,
) -> Result<(), InvalidCharacterError>
fn set_attribute( &self, name: &str, value: &str, ) -> Result<(), InvalidCharacterError>
Sets the value of an attribute on the specified element. If the attribute already
exists, the value is updated; otherwise a new attribute is added with the
specified name and value. Read more
Source§fn scroll_top(&self) -> f64
fn scroll_top(&self) -> f64
Gets the the number of pixels that an element’s content is scrolled vertically. Read more
Source§fn set_scroll_top(&self, value: f64)
fn set_scroll_top(&self, value: f64)
Sets the the number of pixels that an element’s content is scrolled vertically. Read more
Source§fn scroll_left(&self) -> f64
fn scroll_left(&self) -> f64
Gets the the number of pixels that an element’s content is scrolled to the left. Read more
Source§fn set_scroll_left(&self, value: f64)
fn set_scroll_left(&self, value: f64)
Sets the the number of pixels that an element’s content is scrolled to the left. Read more
Source§fn get_attribute_names(&self) -> Vec<String>
fn get_attribute_names(&self) -> Vec<String>
Element.getAttributeNames() returns the attribute names of the element
as an Array of strings. If the element has no attributes it returns an empty array. Read more
Source§fn remove_attribute(&self, name: &str)
fn remove_attribute(&self, name: &str)
Element.removeAttribute removes an attribute from the specified element. Read more
Source§fn has_attributes(&self) -> bool
fn has_attributes(&self) -> bool
The Element.hasAttributes() method returns Boolean value, indicating if
the current element has any attributes or not. Read more
Source§fn closest(&self, selectors: &str) -> Result<Option<Element>, SyntaxError>
fn closest(&self, selectors: &str) -> Result<Option<Element>, SyntaxError>
Returns the closest ancestor of the element (or the element itself) which matches the selectors
given in parameter. If there isn’t such an ancestor, it returns
None
. Read moreSource§fn set_pointer_capture(&self, pointer_id: i32) -> Result<(), InvalidPointerId>
fn set_pointer_capture(&self, pointer_id: i32) -> Result<(), InvalidPointerId>
Designates a specific element as the capture target of future pointer events. Read more
Source§fn release_pointer_capture(
&self,
pointer_id: i32,
) -> Result<(), InvalidPointerId>
fn release_pointer_capture( &self, pointer_id: i32, ) -> Result<(), InvalidPointerId>
Releases pointer capture that was previously set for a specific pointer Read more
Source§fn has_pointer_capture(&self, pointer_id: i32) -> bool
fn has_pointer_capture(&self, pointer_id: i32) -> bool
Returns a boolean indicating if the element has captured the specified pointer Read more
Source§fn insert_adjacent_html(
&self,
position: InsertPosition,
html: &str,
) -> Result<(), InsertAdjacentError>
fn insert_adjacent_html( &self, position: InsertPosition, html: &str, ) -> Result<(), InsertAdjacentError>
Insert nodes from HTML fragment into specified position. Read more
Source§fn insert_html_before(&self, html: &str) -> Result<(), InsertAdjacentError>
fn insert_html_before(&self, html: &str) -> Result<(), InsertAdjacentError>
Insert nodes from HTML fragment before element. Read more
Source§fn prepend_html(&self, html: &str) -> Result<(), InsertAdjacentError>
fn prepend_html(&self, html: &str) -> Result<(), InsertAdjacentError>
Insert nodes from HTML fragment as the first children of the element. Read more
Source§fn append_html(&self, html: &str) -> Result<(), InsertAdjacentError>
fn append_html(&self, html: &str) -> Result<(), InsertAdjacentError>
Insert nodes from HTML fragment as the last children of the element. Read more
Source§fn insert_html_after(&self, html: &str) -> Result<(), InsertAdjacentError>
fn insert_html_after(&self, html: &str) -> Result<(), InsertAdjacentError>
Insert nodes from HTML fragment after element. Read more
Source§fn slot(&self) -> String
fn slot(&self) -> String
The slot property of the Element interface returns the name of the shadow DOM
slot the element is inserted in. Read more
Source§fn attach_shadow(
&self,
mode: ShadowRootMode,
) -> Result<ShadowRoot, AttachShadowError>
fn attach_shadow( &self, mode: ShadowRootMode, ) -> Result<ShadowRoot, AttachShadowError>
Attach a shadow DOM tree to the specified element and returns a reference to its
ShadowRoot
.
It returns a shadow root if successfully attached or None
if the element cannot be attached. Read moreSource§fn shadow_root(&self) -> Option<ShadowRoot>
fn shadow_root(&self) -> Option<ShadowRoot>
Returns the shadow root of the current element or
None
. Read moreSource§impl IEventTarget for SlotElement
impl IEventTarget for SlotElement
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 IHtmlElement for SlotElement
impl IHtmlElement for SlotElement
Source§fn dataset(&self) -> StringMap
fn dataset(&self) -> StringMap
Allows access, both in reading and writing, to all of the custom data attributes (data-*)
set on the element, either in HTML or in the DOM. Read more
Source§fn get_bounding_client_rect(&self) -> Rect
fn get_bounding_client_rect(&self) -> Rect
Returns the size of an element and its position relative to the viewport.
(JavaScript docs)
Source§fn offset_width(&self) -> i32
fn offset_width(&self) -> i32
Returns the layout width of an element. Typically, an element’s offsetWidth is a
measurement which includes the element borders, the element horizontal padding, the
element vertical scrollbar (if present, if rendered) and the element CSS width.
Source§fn offset_height(&self) -> i32
fn offset_height(&self) -> i32
Returns the height of the element including vertical padding and borders, as an
integer.
Source§fn inner_text(&self) -> String
fn inner_text(&self) -> String
A property which represents the “rendered” text content of a node and its descendants.
It approximates the text the user would get if they highlighted the contents of the element
with the cursor and then copied to the clipboard. Read more
Source§impl INode for SlotElement
impl INode for SlotElement
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 SlotElement
impl InstanceOf for SlotElement
Source§impl PartialEq for SlotElement
impl PartialEq for SlotElement
Source§impl ReferenceType for SlotElement
impl ReferenceType for SlotElement
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<'_r> TryFrom<&'_r Reference> for SlotElement
impl<'_r> TryFrom<&'_r Reference> for SlotElement
Source§impl<'_r> TryFrom<&'_r Value> for SlotElement
impl<'_r> TryFrom<&'_r Value> for SlotElement
Source§impl TryFrom<Element> for SlotElement
impl TryFrom<Element> for SlotElement
Source§impl TryFrom<EventTarget> for SlotElement
impl TryFrom<EventTarget> for SlotElement
Source§impl TryFrom<HtmlElement> for SlotElement
impl TryFrom<HtmlElement> for SlotElement
Source§impl TryFrom<Node> for SlotElement
impl TryFrom<Node> for SlotElement
Source§impl TryFrom<Reference> for SlotElement
impl TryFrom<Reference> for SlotElement
Source§impl TryFrom<SlotElement> for Reference
impl TryFrom<SlotElement> for Reference
Source§impl TryFrom<Value> for SlotElement
impl TryFrom<Value> for SlotElement
impl Eq for SlotElement
impl JsSerialize for SlotElement
impl StructuralPartialEq for SlotElement
Auto Trait Implementations§
impl Freeze for SlotElement
impl RefUnwindSafe for SlotElement
impl Send for SlotElement
impl Sync for SlotElement
impl Unpin for SlotElement
impl UnwindSafe for SlotElement
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IChildNode for Twhere
T: IElement,
impl<T> IChildNode for Twhere
T: IElement,
Source§impl<T> IParentNode for Twhere
T: IElement,
impl<T> IParentNode for Twhere
T: IElement,
Source§fn query_selector(&self, selector: &str) -> Result<Option<Element>, SyntaxError>
fn query_selector(&self, selector: &str) -> Result<Option<Element>, SyntaxError>
Returns the first element that is a descendant of the element on which it is
invoked that matches the specified group of selectors. Read more