mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
Fix StdEventableOjbect in lib/std.js
This commit is contained in:
parent
b83e2671f9
commit
6898b9fda9
21
lib/std.js
21
lib/std.js
|
@ -346,10 +346,11 @@ StdEvent.CAPTURING_PHASE = 1; // Not used but to be compatible
|
|||
StdEvent.AT_TARGET = 2;
|
||||
StdEvent.BUBBLING_PHASE = 3; // Not used but to be compatible
|
||||
|
||||
function StdEventTarget() {
|
||||
// maybe, the "EventTarget" is preserved word
|
||||
function StdEventableObject() {
|
||||
this.__events__ = [];
|
||||
|
||||
this.dispatchEvent = function(event) {
|
||||
this.dispatchEvent = function(event, __exception__) {
|
||||
event.target = this;
|
||||
event.isTrusted = false;
|
||||
event.eventPhase = StdEvent.AT_TARGET;
|
||||
|
@ -357,7 +358,11 @@ function StdEventTarget() {
|
|||
for (var i = 0; i < this.__events__.length; i++) {
|
||||
var e = this.__events__[i];
|
||||
if (e.type == event.type && typeof(e.listener) === "function") {
|
||||
e.listener(event);
|
||||
try {
|
||||
e.listener(event, __exception__);
|
||||
} catch (ex) {
|
||||
this.dispatchEvent(new StdEvent("error"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -367,9 +372,9 @@ function StdEventTarget() {
|
|||
this.__events__.push({
|
||||
"type": type,
|
||||
"listener": listener,
|
||||
"counter": StdEventTarget.__counter__
|
||||
"counter": StdEventableObject.__counter__
|
||||
});
|
||||
StdEventTarget.__counter__++;
|
||||
StdEventableObject.__counter__++;
|
||||
} else {
|
||||
throw new TypeError("EventListener must be a function");
|
||||
}
|
||||
|
@ -388,7 +393,7 @@ function StdEventTarget() {
|
|||
}
|
||||
};
|
||||
};
|
||||
StdEventTarget.__counter__ = 0;
|
||||
StdEventableObject.__counter__ = 0;
|
||||
|
||||
function AsyncFunction(f, _filename) {
|
||||
this.f = f;
|
||||
|
@ -450,12 +455,12 @@ global.splitLn = splitLn;
|
|||
global.addslashes = addslashes;
|
||||
global.AsyncFunction = AsyncFunction;
|
||||
|
||||
exports.VERSIONINFO = "Standard Library (std.js) version 0.7.1";
|
||||
exports.VERSIONINFO = "Standard Library (std.js) version 0.7.2";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
||||
exports.Event = StdEvent;
|
||||
exports.EventTarget = StdEventTarget;
|
||||
exports.EventableObject = StdEventableObject;
|
||||
|
||||
exports.alert = alert;
|
||||
exports.cartesian = cartesian;
|
||||
|
|
Loading…
Reference in New Issue
Block a user