Skip to content

Commit 96885dd

Browse files
authored
Arreglar referencia al mismo EventTarget (#172)
* Arreglar referencia al mismo EventTarget * lint? * hopefully this lints, bc I cant run the linter * last lint attempt * Lint
1 parent 902cef1 commit 96885dd

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

js/karel.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ var Runtime = function (world) {
8585
self.disableStackEvents = false;
8686

8787
self.load([['HALT']]);
88+
self.events = new EventTarget();
8889
};
8990

90-
Runtime.prototype = new EventTarget();
91-
9291
Runtime.HALT = 0;
9392
Runtime.LINE = 1;
9493
Runtime.LEFT = 2;
@@ -118,6 +117,22 @@ Runtime.CALL = 25;
118117
Runtime.RET = 26;
119118
Runtime.PARAM = 27;
120119

120+
Runtime.prototype.addEventListener = function (type, listener) {
121+
this.events.addEventListener(type, listener);
122+
};
123+
124+
Runtime.prototype.removeEventListener = function (type, listener) {
125+
this.events.removeEventListener(type, listener);
126+
};
127+
128+
Runtime.prototype.dispatchEvent = function (evt) {
129+
this.events.dispatchEvent(evt);
130+
};
131+
132+
Runtime.prototype.fireEvent = function (type, properties) {
133+
this.events.fireEvent(type, properties);
134+
};
135+
121136
Runtime.prototype.load = function (opcodes) {
122137
var self = this;
123138
var opcode_mapping = [

0 commit comments

Comments
 (0)