Skip to main content

ViewHtmlNode

Trait ViewHtmlNode 

Source
pub trait ViewHtmlNode: ViewNode {
    // Required methods
    fn create_element(tag: Cow<'static, str>) -> Self;
    fn create_element_ns(
        namespace: &'static str,
        tag: Cow<'static, str>,
    ) -> Self;
    fn create_text_node(text: Cow<'static, str>) -> Self;
    fn create_marker_node() -> Self;
    fn set_attribute(&mut self, name: Cow<'static, str>, value: StringAttribute);
    fn set_bool_attribute(
        &mut self,
        name: Cow<'static, str>,
        value: BoolAttribute,
    );
    fn set_property(
        &mut self,
        name: Cow<'static, str>,
        value: MaybeDyn<JsValue>,
    );
    fn set_event_handler(
        &mut self,
        name: Cow<'static, str>,
        handler: impl FnMut(Event) + 'static,
    );
    fn set_inner_html(&mut self, inner_html: Cow<'static, str>);
    fn as_web_sys(&self) -> &Node;
    fn from_web_sys(node: Node) -> Self;

    // Provided method
    fn create_dynamic_text_node(text: Cow<'static, str>) -> Self { ... }
}
Expand description

A trait that should be implemented for anything that represents an HTML node.

Required Methods§

Source

fn create_element(tag: Cow<'static, str>) -> Self

Create a new HTML element.

Source

fn create_element_ns(namespace: &'static str, tag: Cow<'static, str>) -> Self

Create a new HTML element with a XML namespace.

Source

fn create_text_node(text: Cow<'static, str>) -> Self

Create a new HTML text node.

Source

fn create_marker_node() -> Self

Create a new HTML marker (comment) node.

Source

fn set_attribute(&mut self, name: Cow<'static, str>, value: StringAttribute)

Set an HTML attribute.

Source

fn set_bool_attribute(&mut self, name: Cow<'static, str>, value: BoolAttribute)

Set a boolean HTML attribute.

Source

fn set_property(&mut self, name: Cow<'static, str>, value: MaybeDyn<JsValue>)

Set a JS property on an element.

Source

fn set_event_handler( &mut self, name: Cow<'static, str>, handler: impl FnMut(Event) + 'static, )

Set an event handler on an element.

Source

fn set_inner_html(&mut self, inner_html: Cow<'static, str>)

Set the inner HTML value of an element.

Source

fn as_web_sys(&self) -> &Node

Return the raw web-sys node.

Source

fn from_web_sys(node: Node) -> Self

Wrap a raw web-sys node.

Provided Methods§

Source

fn create_dynamic_text_node(text: Cow<'static, str>) -> Self

Create a new HTML text node whose value will be changed dynamically.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§