pub trait CustomElement<V: FromAnyValue + Send + Sync = ()>:
Send
+ Sync
+ 'static {
const NAME: &'static str;
const NAMESPACE: Option<&'static str> = None;
// Required methods
fn create(light_root: NodeMut<'_, V>) -> Self;
fn roots(&self) -> Vec<NodeId>;
fn attributes_changed(
&mut self,
light_node: NodeMut<'_, V>,
attributes: &AttributeMask,
);
// Provided method
fn slot(&self) -> Option<NodeId> { ... }
}
Expand description
A controlled element that renders to a shadow DOM.
Register with RealDom::register_custom_element
This is a simplified custom element trait for elements that can create themselves. For more granular control, implement CustomElementFactory
and CustomElementUpdater
instead.
Required Associated Constants§
Provided Associated Constants§
Required Methods§
Sourcefn create(light_root: NodeMut<'_, V>) -> Self
fn create(light_root: NodeMut<'_, V>) -> Self
Create a new element without mounting it.
The node passed in is the light DOM node. The element should not modify the light DOM node, but it can get the NodeMut::real_dom_mut
from the node to create new nodes.
Sourcefn roots(&self) -> Vec<NodeId>
fn roots(&self) -> Vec<NodeId>
The root node of the custom element. These roots must be not change once the element is created.
Sourcefn attributes_changed(
&mut self,
light_node: NodeMut<'_, V>,
attributes: &AttributeMask,
)
fn attributes_changed( &mut self, light_node: NodeMut<'_, V>, attributes: &AttributeMask, )
Update the custom element’s shadow tree with the new attributes. Called when the attributes of the custom element are changed.
Provided Methods§
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.