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§

source

const NAME: &'static str

The tag of the element

Provided Associated Constants§

source

const NAMESPACE: Option<&'static str> = None

The namespace of the element

Required Methods§

source

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.

source

fn roots(&self) -> Vec<NodeId>

The root node of the custom element. These roots must be not change once the element is created.

source

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§

source

fn slot(&self) -> Option<NodeId>

The slot to render children of the element into. The slot must be not change once the element is created.

Implementors§