Created
May 28, 2018 19:31
-
-
Save kyuwoo-choi/1d59476e5b4423d9e213548cbb540c4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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