class HomeworkVocabularyTask extends HomeworkElement { constructor (id) { super() this.innerHTML = ` ` this.id = id this.setAttribute("result", "unknown") this.setAttribute("state", "edit") this.deleteButton = this.querySelector('img#delete') this.deleteButton.addEventListener("click", this.deleteTask.bind(this)) } connectedCallback() { console.log("New task added to page") } deleteTask() { console.log("Delete line") this.dispatchEvent(new CustomEvent("delete", {detail:{id: this.id}, bubbles: true, cancelable: true})) } getId() { return this.id } } customElements.define('homework-vocabulary-task', HomeworkVocabularyTask)