pub struct DomElement { /* private fields */ }Expand description
A Real DOM representative - element kind
Implementations§
Source§impl DomElement
impl DomElement
pub fn new(name: impl Into<StaticString>) -> Self
Sourcepub fn attr_static(self, name: &'static str, value: &'static str) -> Self
pub fn attr_static(self, name: &'static str, value: &'static str) -> Self
An attribute whose name and value were literals in the source.
Worth its own entry point rather than going through AttrValue: that enum has six
variants, four of them reactive, and a literal can only ever be one of them. Reaching
them through a shared non-generic function keeps Computed, Value and their drop
glue linked into applications that never use a reactive attribute at all. This has no
match to fold and nothing to allocate.
pub fn add_attr_static(&self, name: &'static str, value: &'static str)
Sourcepub fn add_attr(&self, name: impl Into<StaticString>, value: impl IntoAttrValue)
pub fn add_attr(&self, name: impl Into<StaticString>, value: impl IntoAttrValue)
The name is known when the element is built, so class is told apart from everything
else here rather than on every write.
Only class goes through the merger. Every other attribute captures the element’s
DomId - a Copy - and talks to the driver directly, so a reactive href no
longer clones an Rc into its subscription and reaches into a cell to read back an id
it could have kept.
pub fn add_attr_group( self, values: impl IntoIterator<Item = (impl Into<String>, impl Into<AttrGroupValue>)>, ) -> Self
pub fn add_attr_group_item(self, key: String, value: AttrGroupValue) -> Self
pub fn add_child(&self, child_node: impl Into<DomNode>)
pub fn add_child_text(&self, text: impl Into<String>)
pub fn attr( self, name: impl Into<StaticString>, value: impl IntoAttrValue, ) -> Self
pub fn attrs<T: IntoAttrValue>( self, attrs: Vec<(impl Into<StaticString>, T)>, ) -> Self
pub fn child(self, child_node: impl Into<DomNode>) -> Self
pub fn child_text(self, text: impl Into<String>) -> Self
pub fn children<C: Into<DomNode>>(self, children: Vec<C>) -> Self
pub fn css(self, css: impl Into<CssAttrValue>) -> Self
pub fn css_with_class_name( self, css: impl Into<CssAttrValue>, debug_class_name: Option<String>, ) -> Self
pub fn get_ref(&self) -> DomElementRef
pub fn hook_key_down( self, on_hook_key_down: impl Into<Callback1<KeyDownEvent, bool>>, ) -> Self
pub fn hook_key_down_rc( self, on_hook_key_down: Rc<Callback1<KeyDownEvent, bool>>, ) -> Self
pub fn id_dom(&self) -> DomId
pub fn on_blur(self, on_blur: impl Into<Callback<()>>) -> Self
pub fn on_blur_rc(self, on_blur: Rc<Callback<()>>) -> Self
pub fn on_change(self, on_change: impl Into<Callback1<String, ()>>) -> Self
pub fn on_change_rc(self, on_change: Rc<Callback1<String, ()>>) -> Self
pub fn on_change_file( self, on_change_file: impl Into<Callback1<DropFileEvent, ()>>, ) -> Self
pub fn on_change_file_rc( self, on_change_file: Rc<Callback1<DropFileEvent, ()>>, ) -> Self
pub fn on_click(self, on_click: impl Into<Callback1<ClickEvent, ()>>) -> Self
pub fn on_click_rc(self, on_click: Rc<Callback1<ClickEvent, ()>>) -> Self
pub fn on_dropfile( self, on_dropfile: impl Into<Callback1<DropFileEvent, ()>>, ) -> Self
pub fn on_dropfile_rc( self, on_dropfile: Rc<Callback1<DropFileEvent, ()>>, ) -> Self
pub fn on_input(self, on_input: impl Into<Callback1<String, ()>>) -> Self
pub fn on_input_rc(self, on_input: Rc<Callback1<String, ()>>) -> Self
pub fn on_intersect( self, on_intersect: impl Into<Callback1<IntersectionEvent, ()>>, ) -> Self
Sourcepub fn on_intersect_rc(
self,
on_intersect: Rc<Callback1<IntersectionEvent, ()>>,
) -> Self
pub fn on_intersect_rc( self, on_intersect: Rc<Callback1<IntersectionEvent, ()>>, ) -> Self
Observe this element with a browser IntersectionObserver. The callback
fires whenever the element’s intersection with the (default) root
changes, receiving an IntersectionEvent.
Dropping the element disconnects the observer.