Add event.stopped, a boolean that is set to when Event#stop is called.
This commit is contained in:
parent
18969c5159
commit
67cf750956
|
@ -82,8 +82,9 @@ Event.Methods = (function() {
|
|||
|
||||
stop: function(event) {
|
||||
Event.extend(event);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
event.stopped = true;
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -208,8 +208,23 @@
|
|||
assert(eventResults.windowLoad, "windowLoad");
|
||||
assert(eventResults.windowLoad.endOfDocument, "windowLoad.endOfDocument");
|
||||
assert(eventResults.windowLoad.contentLoaded, "windowLoad.contentLoaded");
|
||||
}},
|
||||
|
||||
testEventStopped: function() { with(this) {
|
||||
var span = $("span"), event;
|
||||
|
||||
span.observe("test:somethingHappened", function() { });
|
||||
event = span.fire("test:somethingHappened");
|
||||
assert(!event.stopped, "event.stopped should be false with an empty observer");
|
||||
span.stopObserving("test:somethingHappened");
|
||||
|
||||
span.observe("test:somethingHappened", function(e) { e.stop() });
|
||||
event = span.fire("test:somethingHappened");
|
||||
assert(event.stopped, "event.stopped should be true for an observer that calls stop");
|
||||
span.stopObserving("test:somethingHappened");
|
||||
}}
|
||||
|
||||
|
||||
}, 'testlog');
|
||||
|
||||
document.observe("dom:loaded", function(event) {
|
||||
|
|
Loading…
Reference in New Issue