[][src]Struct savory_html::prelude::El

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>,
}

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: Tagattrs: Attrsstyle: Styleevent_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>

Implementations

impl<Ms> El<Ms>[src]

pub fn empty(tag: Tag) -> El<Ms>[src]

Create an empty element, specifying only the tag

pub fn empty_svg(tag: Tag) -> El<Ms>[src]

Create an empty SVG element, specifying only the tag

pub fn from_markdown(markdown: &str) -> Vec<Node<Ms>>[src]

Create elements from a markdown string. Note: All additional markdown extensions enabled.

pub fn from_html(html: &str) -> Vec<Node<Ms>>[src]

Create elements from an HTML string.

pub fn add_child(&mut self, element: Node<Ms>) -> &mut El<Ms>[src]

Add a new child to the element

pub fn add_attr(
    &mut self,
    key: impl Into<Cow<'static, str>>,
    val: impl Into<AtValue>
) -> &mut El<Ms>
[src]

Add an attribute (eg class, or href)

pub fn add_class(&mut self, name: impl Into<Cow<'static, str>>) -> &mut El<Ms>[src]

Add a class. May be cleaner than add_attr

pub fn add_style(
    &mut self,
    key: impl Into<St>,
    val: impl Into<CSSValue>
) -> &mut El<Ms>
[src]

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

pub fn add_event_handler(
    &mut self,
    event_handler: EventHandler<Ms>
) -> &mut El<Ms>
[src]

Add a new event handler.

pub fn add_text(&mut self, text: impl Into<Cow<'static, str>>) -> &mut El<Ms>[src]

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

pub fn replace_text(
    &mut self,
    text: impl Into<Cow<'static, str>>
) -> &mut El<Ms>
[src]

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

pub fn get_text(&self) -> String[src]

pub fn warn_about_script_tags(&self)[src]

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

pub fn strip_ws_nodes_from_self_and_children(&mut self)[src]

Remove websys nodes.

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

Is it a custom element?

Trait Implementations

impl<Msg> AddForEl<&'static str> for El<Msg>[src]

impl<Msg> AddForEl<Class> for El<Msg>[src]

impl<Msg> AddForEl<Cow<'static, str>> for El<Msg>[src]

impl<Msg> AddForEl<Node<Msg>> for El<Msg>[src]

impl<Msg> AddForEl<String> for El<Msg>[src]

impl<Msg> AddForEl<Style> for El<Msg>[src]

impl<Msg> AddForEl<Vec<Node<Msg>>> for El<Msg>[src]

impl<Ms> Clone for El<Ms>[src]

impl<Ms> Debug for El<Ms> where
    Ms: Debug
[src]

impl<Msg> ElExt<Msg> for El<Msg>[src]

impl<Msg: 'static> EventsApi<Msg> for El<Msg>[src]

impl<'_, Ms> From<&'_ Element> for El<Ms>[src]

fn from(ws_el: &Element) -> El<Ms>[src]

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

impl<Ms, OtherMs> MessageMapper<Ms, OtherMs> for El<Ms> where
    Ms: 'static,
    OtherMs: 'static, 
[src]

type SelfWithOtherMs = El<OtherMs>

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

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.

impl<Msg> SetForEl<&'static str> for El<Msg>[src]

impl<Msg> SetForEl<Attributes> for El<Msg>[src]

impl<Msg> SetForEl<Cow<'static, str>> for El<Msg>[src]

impl<Msg> SetForEl<Node<Msg>> for El<Msg>[src]

impl<Msg> SetForEl<String> for El<Msg>[src]

impl<Msg> SetForEl<Style> for El<Msg>[src]

impl<T: Into<Attribute>, Msg> SetForEl<T> for El<Msg>[src]

impl<Msg> SetForEl<Vec<Node<Msg>>> for El<Msg>[src]

impl<Msg> TryAddForEl<Option<&'static str>> for El<Msg>[src]

impl<Msg> TryAddForEl<Option<Class>> for El<Msg>[src]

impl<Msg> TryAddForEl<Option<Cow<'static, str>>> for El<Msg>[src]

impl<Msg> TryAddForEl<Option<Node<Msg>>> for El<Msg>[src]

impl<Msg> TryAddForEl<Option<String>> for El<Msg>[src]

impl<Msg> TryAddForEl<Option<Style>> for El<Msg>[src]

impl<Msg> TryAddForEl<Option<Vec<Node<Msg>>>> for El<Msg>[src]

impl<Msg> TrySetForEl<Option<&'static str>> for El<Msg>[src]

impl<Msg> TrySetForEl<Option<Cow<'static, str>>> for El<Msg>[src]

impl<Msg> TrySetForEl<Option<Node<Msg>>> for El<Msg>[src]

impl<Msg> TrySetForEl<Option<String>> for El<Msg>[src]

impl<Msg> TrySetForEl<Option<Style>> for El<Msg>[src]

impl<T: Into<Attribute>, Msg> TrySetForEl<Option<T>> for El<Msg>[src]

impl<Msg> TrySetForEl<Option<Vec<Node<Msg>>>> for El<Msg>[src]

impl<Ms> UpdateEl<Ms> for El<Ms>[src]

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

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

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> Sealed<T> for T where
    T: ?Sized

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.

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