Skip to content

Commit

Permalink
Arreglar referencia al mismo EventTarget (#172)
Browse files Browse the repository at this point in the history
* Arreglar referencia al mismo EventTarget

* lint?

* hopefully this lints, bc I cant run the linter

* last lint attempt

* Lint
  • Loading branch information
kishtarn555 authored Jul 7, 2024
1 parent 902cef1 commit 96885dd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions js/karel.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ var Runtime = function (world) {
self.disableStackEvents = false;

self.load([['HALT']]);
self.events = new EventTarget();
};

Runtime.prototype = new EventTarget();

Runtime.HALT = 0;
Runtime.LINE = 1;
Runtime.LEFT = 2;
Expand Down Expand Up @@ -118,6 +117,22 @@ Runtime.CALL = 25;
Runtime.RET = 26;
Runtime.PARAM = 27;

Runtime.prototype.addEventListener = function (type, listener) {
this.events.addEventListener(type, listener);
};

Runtime.prototype.removeEventListener = function (type, listener) {
this.events.removeEventListener(type, listener);
};

Runtime.prototype.dispatchEvent = function (evt) {
this.events.dispatchEvent(evt);
};

Runtime.prototype.fireEvent = function (type, properties) {
this.events.fireEvent(type, properties);
};

Runtime.prototype.load = function (opcodes) {
var self = this;
var opcode_mapping = [
Expand Down

0 comments on commit 96885dd

Please sign in to comment.