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: Listener
s in El
’s event_handler_manager
are not cloned, but recreated during VDOM patching.
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
sourceimpl<Ms> El<Ms>
impl<Ms> El<Ms>
sourcepub fn from_html(namespace: Option<&Namespace>, html: &str) -> Vec<Node<Ms>>
pub fn from_html(namespace: Option<&Namespace>, html: &str) -> Vec<Node<Ms>>
Create elements from an HTML string.
sourcepub fn add_attr(
&mut self,
key: impl Into<Cow<'static, str>>,
val: impl Into<AtValue>
) -> &mut Self
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)
sourcepub fn add_class(&mut self, name: impl Into<Cow<'static, str>>) -> &mut Self
pub fn add_class(&mut self, name: impl Into<Cow<'static, str>>) -> &mut Self
Add a class. May be cleaner than add_attr
sourcepub fn add_style(
&mut self,
key: impl Into<St>,
val: impl Into<CSSValue>
) -> &mut Self
pub fn add_style(
&mut self,
key: impl Into<St>,
val: impl Into<CSSValue>
) -> &mut Self
Add a new style (eg display, or height),
sourcepub fn add_event_handler(
&mut self,
event_handler: EventHandler<Ms>
) -> &mut Self
pub fn add_event_handler(
&mut self,
event_handler: EventHandler<Ms>
) -> &mut Self
Add a new event handler.
sourcepub fn add_text(&mut self, text: impl Into<Cow<'static, str>>) -> &mut Self
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).
sourcepub fn replace_text(&mut self, text: impl Into<Cow<'static, str>>) -> &mut Self
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.
pub fn get_text(&self) -> String
Warn user about potential bugs when having scripts and Takeover
mount type.
sourcepub fn strip_ws_nodes_from_self_and_children(&mut self)
pub fn strip_ws_nodes_from_self_and_children(&mut self)
Remove websys nodes.
Trait Implementations
sourceimpl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for El<Ms>
impl<Ms: 'static, OtherMs: 'static> MessageMapper<Ms, OtherMs> for El<Ms>
sourcefn map_msg(self, f: impl FnOnce(Ms) -> OtherMs + 'static + Clone) -> El<OtherMs>
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>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more