mirror of
https://github.com/zaphar/wasm-web-components.git
synced 2025-07-25 20:20:01 -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 {{
|
"class {name} extends HTMLElement {{
|
||||||
constructor() {{
|
constructor() {{
|
||||||
super();
|
super();
|
||||||
this._impl = impl();
|
var self = this;
|
||||||
|
self._impl = impl();
|
||||||
|
self._impl.init();
|
||||||
}}
|
}}
|
||||||
|
|
||||||
connectedCallback() {{
|
connectedCallback() {{
|
||||||
|
@ -142,6 +142,11 @@ pub trait WebComponentDef: IntoWasmAbi + Default {
|
|||||||
/// Each method is optional. You only need to implement the ones
|
/// Each method is optional. You only need to implement the ones
|
||||||
/// you want to specify behavior for.
|
/// you want to specify behavior for.
|
||||||
pub trait WebComponentBinding: WebComponentDef {
|
pub trait WebComponentBinding: WebComponentDef {
|
||||||
|
/// Called during element construction.
|
||||||
|
fn init(&self, _element: &HtmlElement) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
/// Called when the web component is connected to the DOM.
|
/// Called when the web component is connected to the DOM.
|
||||||
/// This is when you should do any setup like attaching a ShadowDom
|
/// This is when you should do any setup like attaching a ShadowDom
|
||||||
/// or appending elements.
|
/// or appending elements.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user