Struct leptos::HtmlElement
source · pub struct HtmlElement<El>where
El: ElementDescriptor,{ /* private fields */ }
Expand description
Represents an HTML element.
Implementations§
source§impl<El> HtmlElement<El>where
El: ElementDescriptor + 'static,
impl<El> HtmlElement<El>where
El: ElementDescriptor + 'static,
sourcepub fn into_any(self) -> HtmlElement<AnyElement>
pub fn into_any(self) -> HtmlElement<AnyElement>
Converts this element into HtmlElement<AnyElement>
.
sourcepub fn id(self, id: impl Into<Cow<'static, str>>) -> HtmlElement<El>
pub fn id(self, id: impl Into<Cow<'static, str>>) -> HtmlElement<El>
Adds an id
to the element.
sourcepub fn node_ref(self, node_ref: &NodeRef<HtmlElement<El>>) -> HtmlElement<El>where
HtmlElement<El>: Clone,
pub fn node_ref(self, node_ref: &NodeRef<HtmlElement<El>>) -> HtmlElement<El>where
HtmlElement<El>: Clone,
Binds the element reference to NodeRef
.
sourcepub fn on_mount(
self,
f: impl FnOnce(HtmlElement<El>) + 'static
) -> HtmlElement<El>
pub fn on_mount(
self,
f: impl FnOnce(HtmlElement<El>) + 'static
) -> HtmlElement<El>
Runs the callback when this element has been mounted to the DOM.
Important Note
This method will only ever run at most once. If this element is unmounted and remounted, or moved somewhere else, it will not re-run unless you call this method again.
sourcepub fn attr(
self,
name: impl Into<Cow<'static, str>>,
attr: impl IntoAttribute
) -> HtmlElement<El>
pub fn attr(
self,
name: impl Into<Cow<'static, str>>,
attr: impl IntoAttribute
) -> HtmlElement<El>
Adds an attribute to this element.
sourcepub fn class(
self,
name: impl Into<Cow<'static, str>>,
class: impl IntoClass
) -> HtmlElement<El>
pub fn class(
self,
name: impl Into<Cow<'static, str>>,
class: impl IntoClass
) -> HtmlElement<El>
Adds a class to an element.
sourcepub fn prop(
self,
name: impl Into<Cow<'static, str>>,
value: impl IntoProperty
) -> HtmlElement<El>
pub fn prop(
self,
name: impl Into<Cow<'static, str>>,
value: impl IntoProperty
) -> HtmlElement<El>
Sets a property on an element.
sourcepub fn on<E>(
self,
event: E,
event_handler: impl FnMut(<E as EventDescriptor>::EventType) + 'static
) -> HtmlElement<El>where
E: EventDescriptor + 'static,
pub fn on<E>(
self,
event: E,
event_handler: impl FnMut(<E as EventDescriptor>::EventType) + 'static
) -> HtmlElement<El>where
E: EventDescriptor + 'static,
Adds an event listener to this element.
sourcepub fn child(self, child: impl IntoView) -> HtmlElement<El>
pub fn child(self, child: impl IntoView) -> HtmlElement<El>
Adds a child to this element.
sourcepub fn inner_html(self, html: impl Into<Cow<'static, str>>) -> HtmlElement<El>
pub fn inner_html(self, html: impl Into<Cow<'static, str>>) -> HtmlElement<El>
Sets the inner HTML of this element from the provided string slice.
Security
Be very careful when using this method. Always remember to sanitize the input to avoid a cross-site scripting (XSS) vulnerability.
Trait Implementations§
source§impl<El> Clone for HtmlElement<El>where
El: Clone + ElementDescriptor,
impl<El> Clone for HtmlElement<El>where
El: Clone + ElementDescriptor,
source§fn clone(&self) -> HtmlElement<El>
fn clone(&self) -> HtmlElement<El>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more