mirror of
https://github.com/zaphar/wasm-web-components.git
synced 2025-07-21 19:40:30 -04:00
Setup event handling scaffolding
This commit is contained in:
parent
94e8ee07c6
commit
e1d1b2c80b
@ -143,6 +143,10 @@ fn expand_struct_trait_shim(struct_name: &Ident, observed_attrs: Literal) -> syn
|
||||
attributeChangedCallback(name, oldValue, newValue) {{
|
||||
this._impl.attribute_changed_impl(this, name, oldValue, newValue);
|
||||
}}
|
||||
|
||||
handleComponentEvent(evt) {{
|
||||
this._impl.handle_component_event_impl(this, evt);
|
||||
}}
|
||||
}}
|
||||
customElements.define(\"{element_name}\", {name});
|
||||
var element = customElements.get(\"{element_name}\");
|
||||
@ -211,6 +215,11 @@ fn expand_wasm_shim(struct_name: &Ident) -> syn::ItemImpl {
|
||||
use #trait_path;
|
||||
self.attribute_changed(element, name, old_value, new_value);
|
||||
}
|
||||
|
||||
pub fn handle_component_event_impl(&self, element: &web_sys::HtmlElement, event: &web_sys::Event) {
|
||||
use #trait_path;
|
||||
self.handle_event(element, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,10 @@ pub trait WebComponentBinding: WebComponentDef {
|
||||
) {
|
||||
// noop
|
||||
}
|
||||
|
||||
fn handle_event(&self, _element: &HtmlElement, _event: &Event) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
/// Marker trait used in the generated shims to assert that their are Rust implemtntations
|
||||
|
Loading…
x
Reference in New Issue
Block a user