Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/deebloo/ts-custom-elements

Typescript interfaces and decorators for custom elements v1
https://github.com/deebloo/ts-custom-elements

Last synced: 3 months ago
JSON representation

Typescript interfaces and decorators for custom elements v1

Awesome Lists containing this project

README

        

# ts-custom-elements
Typescript interfaces and decorators for custom elements v1

```bash
npm i --save ts-custom-elements
```

example:
```ts
import { CustomElement, OnConnected, OnDisconnected } from 'ts-custom-elements';

@CustomElement({
tagName: 'foo-bar'
})
class TestElement extends HTMLElement implements OnConnected, OnDisconnected {
connectedCallback() {
this.innerHTML = 'I have been rendered!';

this.addEventListener('click', this.onClick.bind(this));
}

disconnectedCallback() {
this.removeEventListener('click', this.onClick);
}

onClick() {
this.innerHTML = 'I was clicked!';
}
}
```