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§
Sourcefn create_element(tag: Cow<'static, str>) -> Self
fn create_element(tag: Cow<'static, str>) -> Self
Create a new HTML element.
Sourcefn create_element_ns(namespace: &'static str, tag: Cow<'static, str>) -> Self
fn create_element_ns(namespace: &'static str, tag: Cow<'static, str>) -> Self
Create a new HTML element with a XML namespace.
Sourcefn create_text_node(text: Cow<'static, str>) -> Self
fn create_text_node(text: Cow<'static, str>) -> Self
Create a new HTML text node.
Sourcefn create_marker_node() -> Self
fn create_marker_node() -> Self
Create a new HTML marker (comment) node.
Sourcefn set_attribute(&mut self, name: Cow<'static, str>, value: StringAttribute)
fn set_attribute(&mut self, name: Cow<'static, str>, value: StringAttribute)
Set an HTML attribute.
Sourcefn set_bool_attribute(&mut self, name: Cow<'static, str>, value: BoolAttribute)
fn set_bool_attribute(&mut self, name: Cow<'static, str>, value: BoolAttribute)
Set a boolean HTML attribute.
Sourcefn set_property(&mut self, name: Cow<'static, str>, value: MaybeDyn<JsValue>)
fn set_property(&mut self, name: Cow<'static, str>, value: MaybeDyn<JsValue>)
Set a JS property on an element.
Sourcefn set_event_handler(
&mut self,
name: Cow<'static, str>,
handler: impl FnMut(Event) + 'static,
)
fn set_event_handler( &mut self, name: Cow<'static, str>, handler: impl FnMut(Event) + 'static, )
Set an event handler on an element.
Sourcefn set_inner_html(&mut self, inner_html: Cow<'static, str>)
fn set_inner_html(&mut self, inner_html: Cow<'static, str>)
Set the inner HTML value of an element.
Sourcefn as_web_sys(&self) -> &Node
fn as_web_sys(&self) -> &Node
Return the raw web-sys node.
Sourcefn from_web_sys(node: Node) -> Self
fn from_web_sys(node: Node) -> Self
Wrap a raw web-sys node.
Provided Methods§
Sourcefn create_dynamic_text_node(text: Cow<'static, str>) -> Self
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".