extends dispatchEvent for custom elements enabling onxxx prop and inline attribute eventhandlers
npm install with-events
extends dispatchEvent for custom elements enabling onxxx prop and inline attribute eventhandlers
🔧 Install
· 🧩 Example
· 📜 API docs
· 🔥 Releases
· 💪🏼 Contribute
· 🖐️ Help
*
``sh`
$ npm i with-events
#### Table of Contents
* withEvents
* Parameters
Constructs a base factory with modified dispatchEvent thatonxxx
will invoke inline handlers as usual with HTML.
`ts
class Foo extends withEvents<{
foo: CustomEvent<{ bar: string }>
}>(HTMLElement) {
// your component here
}
customElements.define('x-foo', Foo)
const foo = new Foo()
// this is now typed properly
foo.onfoo = ({ detail }) => console.log(detail.bar)
foo.dispatchEvent(new CustomEvent('foo', { detail: { bar: 'hello' } }))
// console => 'hello'
`
#### Parameters
* parent` CustomElementConstructor A HTMLElement derived class
All contributions are welcome!
MIT © 2022
stagas