Skip to content

Commit 4f288fc

Browse files
committed
Set events on Collection as a private variable
1 parent 51889b6 commit 4f288fc

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

src/collection.js

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,52 @@ import { Events } from './events.js';
88
*/
99

1010
export class Collection extends Array {
11-
1211
// Warning: Multiple inheritance hack
1312
/**
1413
* @private
1514
*/
16-
_events = new Events();
15+
#events = new Events();
1716

1817
// Getters and setters aren't enumerable
1918
get _bound() {
20-
return this._events._bound;
19+
return this.#events._bound;
2120
}
2221
set _bound(v) {
23-
this._events._bound = v;
22+
this.#events._bound = v;
2423
}
2524

2625
addEventListener() {
27-
return this._events.addEventListener.apply(this, arguments);
26+
return this.#events.addEventListener.apply(this, arguments);
2827
}
2928
on() {
30-
return this._events.on.apply(this, arguments);
29+
return this.#events.on.apply(this, arguments);
3130
}
3231
bind() {
33-
return this._events.bind.apply(this, arguments);
32+
return this.#events.bind.apply(this, arguments);
3433
}
3534
removeEventListener() {
36-
return this._events.removeEventListener.apply(this, arguments);
35+
return this.#events.removeEventListener.apply(this, arguments);
3736
}
3837
off() {
39-
return this._events.off.apply(this, arguments);
38+
return this.#events.off.apply(this, arguments);
4039
}
4140
unbind() {
42-
return this._events.unbind.apply(this, arguments);
41+
return this.#events.unbind.apply(this, arguments);
4342
}
4443
dispatchEvent() {
45-
return this._events.dispatchEvent.apply(this, arguments);
44+
return this.#events.dispatchEvent.apply(this, arguments);
4645
}
4746
trigger() {
48-
return this._events.trigger.apply(this, arguments);
47+
return this.#events.trigger.apply(this, arguments);
4948
}
5049
listen() {
51-
return this._events.listen.apply(this, arguments);
50+
return this.#events.listen.apply(this, arguments);
5251
}
5352
ignore() {
54-
return this._events.ignore.apply(this, arguments);
53+
return this.#events.ignore.apply(this, arguments);
5554
}
5655

5756
constructor() {
58-
5957
super();
6058

6159
if (arguments[0] && Array.isArray(arguments[0])) {
@@ -65,7 +63,6 @@ export class Collection extends Array {
6563
} else if (arguments.length > 0) {
6664
this.push.apply(this, arguments);
6765
}
68-
6966
}
7067

7168
pop() {
@@ -96,7 +93,10 @@ export class Collection extends Array {
9693
const spliced = super.splice.apply(this, arguments);
9794
this.trigger(Events.Types.remove, spliced);
9895
if (arguments.length > 2) {
99-
const inserted = this.slice(arguments[0], arguments[0] + arguments.length - 2);
96+
const inserted = this.slice(
97+
arguments[0],
98+
arguments[0] + arguments.length - 2
99+
);
100100
this.trigger(Events.Types.insert, inserted);
101101
this.trigger(Events.Types.order);
102102
}
@@ -115,10 +115,6 @@ export class Collection extends Array {
115115
return this;
116116
}
117117

118-
indexOf() {
119-
return super.indexOf.apply(this, arguments);
120-
}
121-
122118
map(func, scope) {
123119
const results = [];
124120
for (let key = 0; key < this.length; key++) {
@@ -133,5 +129,4 @@ export class Collection extends Array {
133129
}
134130
return results;
135131
}
136-
137132
}

0 commit comments

Comments
 (0)