Dom

Struct Dom 

Source
pub struct Dom<Message = (), Command = (), Key = ()> {
    pub attributes: Vec<Attr>,
    pub events: Vec<Event<Message>>,
    pub children: Vec<Dom<Message, Command, Key>>,
    /* private fields */
}
Expand description

A node in the DOM.

Fields§

§attributes: Vec<Attr>

Attributes on this node.

§events: Vec<Event<Message>>

Event handlers associated with this node.

§children: Vec<Dom<Message, Command, Key>>

Children of this node.

Implementations§

Source§

impl<Message, Command, Key> Dom<Message, Command, Key>

Source

pub fn elem(element: &'static str) -> Self

Create a new DOM element node.

Source

pub fn text(value: impl Into<String>) -> Self

Create a new DOM text node.

Source

pub fn component( msg: Message, create: fn(Dispatcher<Message, Command>) -> Box<dyn Component<Message>>, ) -> Self

Create a component.

Source

pub fn key(self, key: impl Into<Key>) -> Self

Add an key to this DOM element.

Source

pub unsafe fn inner_html(self, value: impl Into<String>) -> Self

Set innerHtml on this node. Use with caution as this can be used as an attack vector to execute arbitrary code in the client’s browser.

Source

pub fn attr(self, name: &'static str, value: impl Into<String>) -> Self

Add an attribute to this DOM element.

Source

pub fn event(self, trigger: &'static str, msg: Message) -> Self

Add an event listener to this DOM element.

Source

pub fn on(self, trigger: &'static str, handler: Handler<Message>) -> Self

Add an event listener to this DOM element.

Source

pub fn onchange(self, handler: fn(String) -> Option<Message>) -> Self

Add a change event listener to this DOM element.

Source

pub fn oninput(self, handler: fn(InputEvent) -> Option<Message>) -> Self

Add an input event listener to this DOM element.

Source

pub fn push(self, child: impl Into<Dom<Message, Command, Key>>) -> Self

Append the given element as a child on this DOM element.

Source

pub fn extend( self, iter: impl IntoIterator<Item = Dom<Message, Command, Key>>, ) -> Self

Append the elements returned by the given iterator as children on this DOM element.

Trait Implementations§

Source§

impl<Message: Debug, Command: Debug, Key: Debug> Debug for Dom<Message, Command, Key>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Message: Clone, Command, K> DomIter<Message, Command, K> for Dom<Message, Command, K>

Source§

fn dom_iter<'a>( &'a self, ) -> Box<dyn Iterator<Item = DomItem<'a, Message, Command, K>> + 'a>

Return an iterator over the virtual dom.
Source§

impl<Message, Command, K> Into<Dom<Message, Command, K>> for &str

Source§

fn into(self) -> Dom<Message, Command, K>

Converts this type into the (usually inferred) input type.
Source§

impl<Message, Command, K> Into<Dom<Message, Command, K>> for String

Source§

fn into(self) -> Dom<Message, Command, K>

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<Message, Command, Key> Freeze for Dom<Message, Command, Key>
where Message: Freeze, Key: Freeze,

§

impl<Message, Command, Key> RefUnwindSafe for Dom<Message, Command, Key>
where Message: RefUnwindSafe, Key: RefUnwindSafe,

§

impl<Message, Command, Key> Send for Dom<Message, Command, Key>
where Message: Send, Key: Send,

§

impl<Message, Command, Key> Sync for Dom<Message, Command, Key>
where Message: Sync, Key: Sync,

§

impl<Message, Command, Key> Unpin for Dom<Message, Command, Key>
where Message: Unpin, Key: Unpin,

§

impl<Message, Command, Key> UnwindSafe for Dom<Message, Command, Key>
where Message: UnwindSafe, Key: UnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<M> Update<()> for M

Source§

fn update(&mut self, msg: Message, _commands: &mut Commands<Command>)

Update the model using the given message. Implement this to describe the behavior of your app.
Source§

fn simple_update(&mut self, _msg: Message)

Update the model using the given message. Implement this if your app does not need to use side effecting commands.