pub trait CustomElement {
// Provided methods
fn connected_callback(&mut self) { ... }
fn disconnected_callback(&mut self) { ... }
fn adopted_callback(&mut self) { ... }
fn handle_event(&mut self, _event: Event) { ... }
fn connected_move_callback(&mut self) { ... }
fn attribute_changed_callback(
&mut self,
_name: &str,
_old_value: JsValue,
_new_value: JsValue,
) { ... }
}
Expand description
This trait is the focal point of this crate, and implementing it allows your Rust struct to be used as a custom element.
It specifies all the methods can be called from the JavaScript wrapper class.
All of these functions have been provided default, no-op implementations. You may optionally provide implementations to hook into the custom element lifecycle.
Provided Methods§
Sourcefn connected_callback(&mut self)
fn connected_callback(&mut self)
Called each time the element is added to the document
Sourcefn disconnected_callback(&mut self)
fn disconnected_callback(&mut self)
Called each time the element is removed from the document
Sourcefn adopted_callback(&mut self)
fn adopted_callback(&mut self)
Called each time the element is moved to a new document
Sourcefn handle_event(&mut self, _event: Event)
fn handle_event(&mut self, _event: Event)
Enables using the custom element instance as an event handler catch-all
Sourcefn connected_move_callback(&mut self)
fn connected_move_callback(&mut self)
When defined, this is called instead of connectedCallback() and disconnectedCallback() each time the element is moved to a different place in the DOM via Element.moveBefore().
Sourcefn attribute_changed_callback(
&mut self,
_name: &str,
_old_value: JsValue,
_new_value: JsValue,
)
fn attribute_changed_callback( &mut self, _name: &str, _old_value: JsValue, _new_value: JsValue, )
Called when attributes are changed, added, removed, or replaced