google / google/closure-compiler

handleEvent support

Open
#413 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Closure-compiler doesn't support handleEvent. Is this going to get addressed?

If I add an eventlistener to an element inside a prototype function, e.g

``` js
SomePrototype.prototype.somefunc = function() {
el.addEventlistener("click", this);
};
```

will produce this error;

JSC_TYPE_MISMATCH: actual parameter 2 of Node.prototype.addEventListener does not match formal parameter

While it's completely legit JavaScript since years ago, as long as you have a handleEvent function e.g.

``` js
SomePrototype.prototype.handleEvent = function(e) {
if (e.type === "click") {}; // ...
};
```

I know you can use goog.events for doing things the old fashioned way, but for me that's not an option because
1. I don't support IE8 (since several years)
2. I don't want to use goog.events (e.g. be bound to one minifier for all time). Things change.
3. How handleEvent handles this references makes development so much smoother, since I don't need to use var self = this; everywhere.

I can fix this, but I don't know how the closure-compiler works (I'd have to learn, so it would take some time), so if anyone else can fix this, please do!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.