[][src]Struct sauron_vdom::Element

pub struct Element<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
{ pub tag: T, pub attrs: Vec<Attribute<ATT, EVENT, MSG>>, pub children: Vec<Node<T, ATT, EVENT, MSG>>, pub namespace: Option<&'static str>, }

Represents the element of the virtual node

Fields

tag: T

the element tag, such as div, a, button

attrs: Vec<Attribute<ATT, EVENT, MSG>>

attributes for this element

children: Vec<Node<T, ATT, EVENT, MSG>>

children elements of this element

namespace: Option<&'static str>

namespace of this element, svg elements requires namespace to render correcly in the browser

Implementations

impl<T, ATT, EVENT, MSG> Element<T, ATT, EVENT, MSG> where
    EVENT: 'static,
    MSG: 'static,
    ATT: PartialEq + Ord + ToString + Clone
[src]

pub fn with_tag(tag: T) -> Self[src]

creates an element node with the supplied tag

pub fn get_children(&self) -> &[Node<T, ATT, EVENT, MSG>][src]

returns a refernce to the children of this node

pub fn events(&self) -> Vec<&Attribute<ATT, EVENT, MSG>>[src]

get the attributes that are events

pub fn get_event(&self, name: &ATT) -> Option<&Attribute<ATT, EVENT, MSG>>[src]

return the event as an attribute which matches the event name.

pub fn attributes(&self) -> Vec<Attribute<ATT, EVENT, MSG>>[src]

returns the only the attributes of this element Note: This does not include the events. If you need to access the events, use the attrs field directly.

pub fn get_attr_value(&self, key: &ATT) -> Option<Value>[src]

get all the attributes with the same name and merge their value

pub fn add_attributes(&mut self, attrs: Vec<Attribute<ATT, EVENT, MSG>>)[src]

add attributes to this element

pub fn add_children(&mut self, children: Vec<Node<T, ATT, EVENT, MSG>>)[src]

add children virtual node to this element

pub fn add_event_listener(&mut self, event: ATT, cb: Callback<EVENT, MSG>)[src]

attach a callback to this element

pub fn eldest_child_text(&self) -> Option<&str>[src]

returns the text if this node has only one child and is a text. includes: h1, h2..h6, p,

pub fn is_children_a_node_text(&self) -> bool[src]

check if the children of this node is only 1 and it is a text node

Trait Implementations

impl<T: Clone, ATT: Clone, EVENT: Clone, MSG: Clone> Clone for Element<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

impl<T: Debug, ATT: Debug, EVENT: Debug, MSG: Debug> Debug for Element<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

impl<T: Default, ATT: Default, EVENT: Default, MSG: Default> Default for Element<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

impl<T, ATT, EVENT, MSG> From<Element<T, ATT, EVENT, MSG>> for Node<T, ATT, EVENT, MSG> where
    ATT: Clone
[src]

impl<T: PartialEq, ATT: PartialEq, EVENT: PartialEq, MSG: PartialEq> PartialEq<Element<T, ATT, EVENT, MSG>> for Element<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

impl<T, ATT, EVENT, MSG> StructuralPartialEq for Element<T, ATT, EVENT, MSG> where
    MSG: 'static,
    EVENT: 'static,
    ATT: Clone
[src]

Auto Trait Implementations

impl<T, ATT, EVENT, MSG> !RefUnwindSafe for Element<T, ATT, EVENT, MSG>

impl<T, ATT, EVENT, MSG> !Send for Element<T, ATT, EVENT, MSG>

impl<T, ATT, EVENT, MSG> !Sync for Element<T, ATT, EVENT, MSG>

impl<T, ATT, EVENT, MSG> Unpin for Element<T, ATT, EVENT, MSG> where
    ATT: Unpin,
    T: Unpin

impl<T, ATT, EVENT, MSG> !UnwindSafe for Element<T, ATT, EVENT, MSG>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.