I have a native html web component that simplified looks like the thing below.
What it does is, when clicking on the component element with the middle mouse button, it will be removed. It works just as expected.
class MyComponent extends HTMLElement {
constructor() {
super();
}
connectedCallback() {
this.innerHTML = 'Hello World';
this.onMiddleClick();
}
onMiddleClick() {
this.addEventListener("auxclick", (e) => {
if (e.which !== 2) return;
this.remove();
});
}
}
customElements.define("my-component", MyComponent);
Problem
VSCode overline which and say that it's deprecated. I tried to change auxclick to mousedown but which is still overlined.
- What is wrong?
- How can I fix it?
It should be
e.button. It returns a number and1is the middle click.