https://github.com/deebloo/ts-custom-elements
Typescript interfaces and decorators for custom elements v1
https://github.com/deebloo/ts-custom-elements
Last synced: about 1 year ago
JSON representation
Typescript interfaces and decorators for custom elements v1
- Host: GitHub
- URL: https://github.com/deebloo/ts-custom-elements
- Owner: deebloo
- License: mit
- Created: 2016-11-03T20:05:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T08:44:12.000Z (over 2 years ago)
- Last Synced: 2025-03-29T00:51:17.341Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 223 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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!';
}
}
```