Struct seed::virtual_dom::node::el::El

source ·
pub struct El<Ms> {
    pub tag: Tag,
    pub attrs: Attrs,
    pub style: Style,
    pub event_handler_manager: EventHandlerManager<Ms>,
    pub children: Vec<Node<Ms>>,
    pub namespace: Option<Namespace>,
    pub node_ws: Option<Node>,
    pub refs: Vec<SharedNodeWs>,
    pub key: Option<ElKey>,
    pub insert_handlers: Vec<InsertEventHandler<Ms>>,
}
Expand description

A component in our virtual DOM.

Note: Listeners in El’s event_handler_manager are not cloned, but recreated during VDOM patching.

MDN reference web_sys reference

Fields§

§tag: Tag§attrs: Attrs§style: Style§event_handler_manager: EventHandlerManager<Ms>§children: Vec<Node<Ms>>§namespace: Option<Namespace>§node_ws: Option<Node>

The actual DOM element/node.

§refs: Vec<SharedNodeWs>§key: Option<ElKey>§insert_handlers: Vec<InsertEventHandler<Ms>>

Implementations§

source§

impl<Ms> El<Ms>

source

pub fn empty(tag: Tag) -> Self

Create an empty element, specifying only the tag

source

pub fn empty_svg(tag: Tag) -> Self

Create an empty SVG element, specifying only the tag

source

pub fn from_html(namespace: Option<&Namespace>, html: &str) -> Vec<Node<Ms>>

Create elements from an HTML string.

source

pub fn add_child(&mut self, element: Node<Ms>) -> &mut Self

Add a new child to the element

source

pub fn add_attr( &mut self, key: impl Into<Cow<'static, str>>, val: impl Into<AtValue> ) -> &mut Self

Add an attribute (eg class, or href)

source

pub fn add_class(&mut self, name: impl Into<Cow<'static, str>>) -> &mut Self

Add a class. May be cleaner than add_attr

source

pub fn add_style( &mut self, key: impl Into<St>, val: impl Into<CSSValue> ) -> &mut Self

Add a new style (eg display, or height),

source

pub fn add_event_handler(&mut self, event_handler: EventHandler<Ms>) -> &mut Self

Add a new event handler.

source

pub fn add_text(&mut self, text: impl Into<Cow<'static, str>>) -> &mut Self

Add a text node to the element. (ie between the HTML tags).

source

pub fn replace_text(&mut self, text: impl Into<Cow<'static, str>>) -> &mut Self

Replace the element’s text. Removes all text nodes from element, then adds the new one.

source

pub fn get_text(&self) -> String

source

pub fn warn_about_script_tags(&self)

Warn user about potential bugs when having scripts and Takeover mount type.

source

pub fn strip_ws_nodes_from_self_and_children(&mut self)

Remove websys nodes.

source

pub const fn is_custom(&self) -> bool

Is it a custom element?

Trait Implementations§

source§

impl<Ms> Clone for El<Ms>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Ms: Debug> Debug for El<Ms>

source§

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

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

impl<Ms> Display for El<Ms>

source§

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

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

impl<Ms> From<&Element> for El<Ms>

source§

fn from(ws_el: &Element) -> Self

Create a vdom node from a web_sys::Element. Used in creating elements from html strings. Includes children, recursively added.

source§

impl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for El<Ms>

source§

fn map_msg(self, f: impl FnOnce(Ms) -> OtherMs + 'static + Clone) -> El<OtherMs>

Maps an element’s message to have another message.

This allows third party components to integrate with your application without having to know about your Msg type beforehand.

Note

There is an overhead to calling this versus keeping all messages under one type. The deeper the nested structure of children, the more time this will take to run.

§

type SelfWithOtherMs = El<OtherMs>

source§

impl<Ms> UpdateEl<Ms> for El<Ms>

source§

fn update_el(self, el: &mut El<Ms>)

Auto Trait Implementations§

§

impl<Ms> !RefUnwindSafe for El<Ms>

§

impl<Ms> !Send for El<Ms>

§

impl<Ms> !Sync for El<Ms>

§

impl<Ms> Unpin for El<Ms>

§

impl<Ms> !UnwindSafe for El<Ms>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V