Skip to content

Instantly share code, notes, and snippets.

@kyuwoo-choi
Created May 28, 2018 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyuwoo-choi/1d59476e5b4423d9e213548cbb540c4a to your computer and use it in GitHub Desktop.
Save kyuwoo-choi/1d59476e5b4423d9e213548cbb540c4a to your computer and use it in GitHub Desktop.
import { toggle, remove, replace } from '../libs/actions';
...
class TodoItem extends LitRender(HTMLElement) {
...
connectedCallback() {
const root = this.shadowRoot;
...
root.addEventListener('click', handlers.onClick);
...
}
disconnectedCallback() {
const root = this.shadowRoot;
...
root.removeEventListener('click', this._handlers.onClick);
...
}
...
_onClick(event) {
const id = this.todo.id;
const classList = event.path[0].classList;
if (classList.contains('toggle')) {
toggle(id);
} else if (classList.contains('destroy')) {
remove(id);
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment