I have a class EditNote which inherits from ViewNote, the problem is that whenever i try accessing super.removeElement('bible-close') ( which is a method in the super class ) i get a TypeError (Uncaught TypeError: Cannot read property 'call' of undefined)
class ViewNote {
constructor() {
let viewNote = document.querySelector('.view-note');
let viewNoteParent = document.querySelector('.bible-view-note-list');
this.viewNote = () => viewNote;
this.viewNoteParent = () => viewNoteParent;
}
removeParentElement(el) {
this.viewNote().removeAttribute('style');
Array.from(
this.viewNote().querySelectorAll('.bible-view-note-item'),
el => el.remove()
);
}
}
class EditNote extends ViewNote {
constructor() {
super();
super.showNote({
editwidget: true,
listener({content, title, creationDate}, ...args) {
for (let i of args) {
i.addEventListener('click', e => {
let target = e.target;
if (target.className.includes('bible-close')) {
super.removeElement('bible-close');
return ;
}
})
}
}
});
}
}
The problem with the above code is that super.removeParentElement('bible-close'); throws a TypeError. I even tried using the this keyword but it did not work because this is undefined inside the super.showNote method