[whatwg/dom] Better way to maintain this reference on event listener functions (#245)

Sorry if I've missed any previous requests for this feature, but is there any goal to allow callbacks passed to event listeners keep their `this` context without having to store a reference to the this-binded event listener first?

I frequently find myself doing this in my class methods:

```
this.el = document.createElement('div');
this.listener = this.onClick.bind(this); // store a reference just to bind the `this`
this.el.addEventListener('click', this.listener)
```

only to ensure the correct listener mapping gets removed later on in a `destroy`-like function with this code:

```
this.el.removeEventListener('click', this.listener);
```

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/245

Received on Monday, 9 May 2016 09:04:12 UTC