pub struct HtmlElement<El: ElementDescriptor> { /* private fields */ }
Expand description

Represents an HTML element.

Implementations§

source§

impl<El: ElementDescriptor + 'static> HtmlElement<El>

source

pub fn with_view_marker(self, marker: impl Into<String>) -> Self

Adds an optional marker indicating the view macro source.

source

pub fn into_any(self) -> HtmlElement<AnyElement>

Converts this element into HtmlElement<AnyElement>.

source

pub fn id(self, id: impl Into<Cow<'static, str>>) -> Self

Adds an id to the element.

source

pub fn node_ref(self, node_ref: NodeRef<El>) -> Selfwhere Self: Clone,

Binds the element reference to NodeRef.

source

pub fn on_mount(self, f: impl FnOnce(Self) + 'static) -> Self

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.

source

pub fn is_mounted(&self) -> bool

Checks to see if this element is mounted to the DOM as a child of body.

This method will always return None on non-wasm CSR targets.

source

pub fn attr( self, name: impl Into<Cow<'static, str>>, attr: impl IntoAttribute ) -> Self

Adds an attribute to this element.

source

pub fn class( self, name: impl Into<Cow<'static, str>>, class: impl IntoClass ) -> Self

Adds a class to an element.

source

pub fn classes(self, classes: impl Into<Cow<'static, str>>) -> Self

Adds a list of classes separated by ASCII whitespace to an element.

source

pub fn dyn_classes<I, C>(self, classes_signal: impl Fn() -> I + 'static) -> Selfwhere I: IntoIterator<Item = C>, C: Into<Cow<'static, str>>,

Sets the class on the element as the class signal changes.

source

pub fn prop( self, name: impl Into<Cow<'static, str>>, value: impl IntoProperty ) -> Self

Sets a property on an element.

source

pub fn on<E: EventDescriptor + 'static>( self, event: E, event_handler: impl FnMut(E::EventType) + 'static ) -> Self

Adds an event listener to this element.

source

pub fn child(self, child: impl IntoView) -> Self

Adds a child to this element.

source

pub fn inner_html(self, html: impl Into<Cow<'static, str>>) -> Self

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 + ElementDescriptor> Clone for HtmlElement<El>

source§

fn clone(&self) -> HtmlElement<El>

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<El: ElementDescriptor> Debug for HtmlElement<El>

source§

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

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

impl<El> Deref for HtmlElement<El>where El: ElementDescriptor + Deref,

§

type Target = <El as Deref>::Target

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<El: ElementDescriptor> IntoView for HtmlElement<El>

source§

fn into_view(self, _: Scope) -> View

Converts the value into View.

Auto Trait Implementations§

§

impl<El> !RefUnwindSafe for HtmlElement<El>

§

impl<El> !Send for HtmlElement<El>

§

impl<El> !Sync for HtmlElement<El>

§

impl<El> Unpin for HtmlElement<El>where El: Unpin,

§

impl<El> !UnwindSafe for HtmlElement<El>

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
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.
source§

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

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<El> ElementDescriptorBounds for Elwhere El: Debug,