Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Commit 4369cbc

Browse files
committed
fix(hint): do not crash
Somewhere between v0.14.4 and v4.0.0, `EventEmitter2` started being inconsistent wrt to the arguments passed to the `onAny()` listener; sometimes the `eventType` is passed as the first argument, sometimes it isn't. This caused batarang to crash. This commit fixes it, by accounting for the fact that `eventType` might or might not be passed as a first argument. Fixes #310
1 parent ea0ff19 commit 4369cbc

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

dist/hint.js

100755100644
+11-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@
77
require('./loader.js');
88
require('angular-hint');
99

10-
angular.hint.onAny(function (data, severity) {
10+
angular.hint.onAny(function (event, data, severity) {
11+
// EventEmitter2 usually omits the event type for the argument list (assigning it to `this.event`
12+
// instead), but under certain circumstances it may include it.
13+
if (this.event !== event) {
14+
severity = data;
15+
data = event;
16+
event = this.event;
17+
}
18+
1119
window.postMessage({
1220
__fromBatarang: true,
13-
module: this.event.split(':')[0],
14-
event: this.event,
21+
module: event.split(':')[0],
22+
event: event,
1523
data: data,
1624
severity: severity
1725
}, '*');

hint.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66
require('./loader.js');
77
require('angular-hint');
88

9-
angular.hint.onAny(function (data, severity) {
9+
angular.hint.onAny(function (event, data, severity) {
10+
// EventEmitter2 usually omits the event type for the argument list (assigning it to `this.event`
11+
// instead), but under certain circumstances it may include it.
12+
if (this.event !== event) {
13+
severity = data;
14+
data = event;
15+
event = this.event;
16+
}
17+
1018
window.postMessage({
1119
__fromBatarang: true,
12-
module: this.event.split(':')[0],
13-
event: this.event,
20+
module: event.split(':')[0],
21+
event: event,
1422
data: data,
1523
severity: severity
1624
}, '*');

0 commit comments

Comments
 (0)