Re: [whatwg/dom] Removing event listeners through an identifier (#208)

I don't think anyone would argue that this cannot be handled today. In particular since the feature can be polyfilled with something like:

```js
var origAdd = element.addEventListener;
eventTargets.addEventListener = function(type, fn,  props) {
  if (props.group) {
    if (!this.eventListenerGroups) this.eventListenerGroups = Object.create(null);
    if (!this.eventListenerGroups[props.group]) this.eventListenerGroups[props.group]) = [];
    this.eventListenerGroups[props.group].push({type, fn})
  }
  return origAdd.apply(this, arguments);
} 

var origRemove = eventTargets.removeEventListener;
eventTargets.removeEventListener = function(type, props) {
  if (props.group) {
    if (this.eventListenerGroups && this.eventListenerGroups[props.group]) {
      this.eventListenerGroups[props.group].forEach(entry => origRemove.call(this, entry.type, entry.fn))
    }
  } else {
    return origRemove.apply(this, arguments);
  }
}
```

modulo bugs and hacks :)

But I'm strongly pro an idiomatic event handling API in the core platform.

-- 
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/208#issuecomment-311374981

Received on Tuesday, 27 June 2017 14:26:36 UTC