Skip to main content

DomElement

Struct DomElement 

Source
pub struct DomElement { /* private fields */ }
Expand description

A Real DOM representative - element kind

Implementations§

Source§

impl DomElement

Source

pub fn new(name: impl Into<StaticString>) -> Self

Source

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.

Source

pub fn add_attr_static(&self, name: &'static str, value: &'static str)

Source

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.

Source

pub fn add_attr_group( self, values: impl IntoIterator<Item = (impl Into<String>, impl Into<AttrGroupValue>)>, ) -> Self

Source

pub fn add_attr_group_item(self, key: String, value: AttrGroupValue) -> Self

Source

pub fn add_child(&self, child_node: impl Into<DomNode>)

Source

pub fn add_child_text(&self, text: impl Into<String>)

Source

pub fn attr( self, name: impl Into<StaticString>, value: impl IntoAttrValue, ) -> Self

Source

pub fn attrs<T: IntoAttrValue>( self, attrs: Vec<(impl Into<StaticString>, T)>, ) -> Self

Source

pub fn child(self, child_node: impl Into<DomNode>) -> Self

Source

pub fn child_text(self, text: impl Into<String>) -> Self

Source

pub fn children<C: Into<DomNode>>(self, children: Vec<C>) -> Self

Source

pub fn css(self, css: impl Into<CssAttrValue>) -> Self

Source

pub fn css_with_class_name( self, css: impl Into<CssAttrValue>, debug_class_name: Option<String>, ) -> Self

Source

pub fn get_ref(&self) -> DomElementRef

Source

pub fn hook_key_down( self, on_hook_key_down: impl Into<Callback1<KeyDownEvent, bool>>, ) -> Self

Source

pub fn hook_key_down_rc( self, on_hook_key_down: Rc<Callback1<KeyDownEvent, bool>>, ) -> Self

Source

pub fn id_dom(&self) -> DomId

Source

pub fn on_blur(self, on_blur: impl Into<Callback<()>>) -> Self

Source

pub fn on_blur_rc(self, on_blur: Rc<Callback<()>>) -> Self

Source

pub fn on_change(self, on_change: impl Into<Callback1<String, ()>>) -> Self

Source

pub fn on_change_rc(self, on_change: Rc<Callback1<String, ()>>) -> Self

Source

pub fn on_change_file( self, on_change_file: impl Into<Callback1<DropFileEvent, ()>>, ) -> Self

Source

pub fn on_change_file_rc( self, on_change_file: Rc<Callback1<DropFileEvent, ()>>, ) -> Self

Source

pub fn on_click(self, on_click: impl Into<Callback1<ClickEvent, ()>>) -> Self

Source

pub fn on_click_rc(self, on_click: Rc<Callback1<ClickEvent, ()>>) -> Self

Source

pub fn on_dropfile( self, on_dropfile: impl Into<Callback1<DropFileEvent, ()>>, ) -> Self

Source

pub fn on_dropfile_rc( self, on_dropfile: Rc<Callback1<DropFileEvent, ()>>, ) -> Self

Source

pub fn on_input(self, on_input: impl Into<Callback1<String, ()>>) -> Self

Source

pub fn on_input_rc(self, on_input: Rc<Callback1<String, ()>>) -> Self

Source

pub fn on_intersect( self, on_intersect: impl Into<Callback1<IntersectionEvent, ()>>, ) -> Self

Source

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.

Source

pub fn on_key_down( self, on_key_down: impl Into<Callback1<KeyDownEvent, bool>>, ) -> Self

Source

pub fn on_key_down_rc( self, on_key_down: Rc<Callback1<KeyDownEvent, bool>>, ) -> Self

Source

pub fn on_load(self, on_load: impl Into<Callback<()>>) -> Self

Source

pub fn on_load_rc(self, on_load: Rc<Callback<()>>) -> Self

Source

pub fn on_mouse_down(self, on_mouse_down: impl Into<Callback<bool>>) -> Self

Source

pub fn on_mouse_down_rc(self, on_mouse_down: Rc<Callback<bool>>) -> Self

Source

pub fn on_mouse_enter(self, on_mouse_enter: impl Into<Callback<()>>) -> Self

Source

pub fn on_mouse_enter_rc(self, on_mouse_enter: Rc<Callback<()>>) -> Self

Source

pub fn on_mouse_leave(self, on_mouse_leave: impl Into<Callback<()>>) -> Self

Source

pub fn on_mouse_leave_rc(self, on_mouse_leave: Rc<Callback<()>>) -> Self

Source

pub fn on_mouse_up(self, on_mouse_up: impl Into<Callback<bool>>) -> Self

Source

pub fn on_mouse_up_rc(self, on_mouse_up: Rc<Callback<bool>>) -> Self

Source

pub fn on_submit(self, on_submit: impl Into<Callback<()>>) -> Self

Source

pub fn on_submit_rc(self, on_submit: Rc<Callback<()>>) -> Self

Source

pub fn append_drop_resource(&self, resource: DropResource)

Trait Implementations§

Source§

impl Drop for DomElement

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl EmbedDom for DomElement

Source§

impl From<DomElement> for DomNode

Source§

fn from(node: DomElement) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.