Update documentation a bit.

This commit is contained in:
Jeremy Wall 2023-08-18 17:12:48 -04:00
parent 4f860a242b
commit 1a71426806
2 changed files with 13 additions and 4 deletions

View File

@ -17,6 +17,6 @@
This set of crates should not be considered production ready. WebAssembly is not
quite ready for general use in a Web Component. Getting this to work involved
something of a Rub Goldberg machine involving a Javascript shim and a wasm_bindgen
Rust shim with a several traits. The boilerplate is generated using a proc-macro
something of a Rub Goldberg machine involving a Javascript shim and a wasm\_bindgen
Rust shim with several traits. The boilerplate is generated using a proc-macro
to make it more generally reusable.

View File

@ -46,18 +46,26 @@ pub trait WebComponentDef: IntoWasmAbi + Default {
/// Each method is optional. You only need to implement the ones
/// you want to specify behavior for.
pub trait WebComponentBinding: WebComponentDef {
/// Called when the web component is connected to the DOM.
/// This is when you should do any setup like attaching a ShadowDom
/// or appending elements.
fn connected(&self, _element: &HtmlElement) {
// noop
}
/// Called when the web component is disconnected from the DOM.
fn disconnected(&self, _element: &HtmlElement) {
// noop
}
/// Called When the web component is moved to a new document.
fn adopted(&self, _element: &HtmlElement) {
// noop
}
/// Called when one of the observed attributes has changed.
/// the observedc attributes are listed in the observed_attrs argument to the
/// `#[web_component(observed_attrs = "['attr1', 'attr2']")` attribute.
fn attribute_changed(
&self,
_element: &HtmlElement,
@ -68,6 +76,7 @@ pub trait WebComponentBinding: WebComponentDef {
// noop
}
/// Top level event handler for this custome element.
fn handle_event(&self, _element: &HtmlElement, _event: &Event) {
// noop
}