diff --git a/src/event.js b/src/event.js index f5e8a99..63379cd 100644 --- a/src/event.js +++ b/src/event.js @@ -82,8 +82,9 @@ Event.Methods = (function() { stop: function(event) { Event.extend(event); - event.preventDefault(); - event.stopPropagation(); + event.preventDefault(); + event.stopPropagation(); + event.stopped = true; } }; })(); diff --git a/test/unit/event.html b/test/unit/event.html index 87e4647..036f203 100644 --- a/test/unit/event.html +++ b/test/unit/event.html @@ -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) {