Skip to content

Instantly share code, notes, and snippets.

@Westbrook
Created Apr 10, 2019
Embed
What would you like to do?
import htm from 'https://unpkg.com/htm?module'; // for parity of renderer plus access to element properties
const handler = (e) => console.log("You've got an event at the parent level:",e);
const eventToComponent = htm`<MyComponent onSomething=${handler} />`;
const eventToCustomElement = htm`<my-component onSomething=${handler} />`;
// OR, you can use capturing to manage this sort of thing via central data store
document.body.addEventListener('something', e => {
e.stopPropagation();
console.log("You've got an event at the central data store level:",e);
// Do central data store stuff...
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment