mirror of
https://github.com/zaphar/wasm-web-components.git
synced 2025-07-23 19:59:48 -04:00
feat: init hook for element constructor
This commit is contained in:
parent
c39293636d
commit
8956f485a8
@ -133,7 +133,9 @@ fn expand_wc_struct_trait_shim(
|
||||
"class {name} extends HTMLElement {{
|
||||
constructor() {{
|
||||
super();
|
||||
this._impl = impl();
|
||||
var self = this;
|
||||
self._impl = impl();
|
||||
self._impl.init();
|
||||
}}
|
||||
|
||||
connectedCallback() {{
|
||||
|
@ -142,6 +142,11 @@ 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 during element construction.
|
||||
fn init(&self, _element: &HtmlElement) {
|
||||
// noop
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user