Trait ViewHtmlNode
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: MaybeDyn<Option<Cow<'static, str>>>,
);
fn set_bool_attribute(
&mut self,
name: Cow<'static, str>,
value: MaybeDyn<bool>,
);
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§
fn create_element(tag: Cow<'static, str>) -> Self
fn create_element(tag: Cow<'static, str>) -> Self
Create a new HTML element.
fn 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.
fn create_text_node(text: Cow<'static, str>) -> Self
fn create_text_node(text: Cow<'static, str>) -> Self
Create a new HTML text node.
fn create_marker_node() -> Self
fn create_marker_node() -> Self
Create a new HTML marker (comment) node.
fn set_attribute(
&mut self,
name: Cow<'static, str>,
value: MaybeDyn<Option<Cow<'static, str>>>,
)
fn set_attribute( &mut self, name: Cow<'static, str>, value: MaybeDyn<Option<Cow<'static, str>>>, )
Set an HTML attribute.
fn set_bool_attribute(&mut self, name: Cow<'static, str>, value: MaybeDyn<bool>)
fn set_bool_attribute(&mut self, name: Cow<'static, str>, value: MaybeDyn<bool>)
Set a boolean HTML attribute.
fn 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.
fn 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.
fn 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.
fn as_web_sys(&self) -> &Node
fn as_web_sys(&self) -> &Node
Return the raw web-sys node.
fn from_web_sys(node: Node) -> Self
fn from_web_sys(node: Node) -> Self
Wrap a raw web-sys node.
Provided Methods§
fn 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", so this trait is not object safe.