prototype: Make sure Element#observe is always chainable.
This commit is contained in:
parent
d2974cfca3
commit
11f25aa995
@ -1,6 +1,6 @@
|
||||
*SVN*
|
||||
|
||||
* Make sure Element#stopObserving is always chainable. [sam]
|
||||
* Make sure Element#observe and Element#stopObserving are always chainable. [sam]
|
||||
|
||||
* Event.fire/Element#fire now returns the newly-fired event instead of the event's target element. [sam]
|
||||
|
||||
|
@ -170,7 +170,7 @@ Object.extend(Event, (function() {
|
||||
var id = getEventID(element), name = getDOMEventName(eventName);
|
||||
|
||||
var wrapper = createWrapper(id, eventName, handler);
|
||||
if (!wrapper) return false;
|
||||
if (!wrapper) return element;
|
||||
|
||||
if (element.addEventListener) {
|
||||
element.addEventListener(name, wrapper, false);
|
||||
|
@ -183,15 +183,22 @@
|
||||
assertEqual(0, Event.cache[eventID].somethingHappened.length);
|
||||
}},
|
||||
|
||||
testStopObservingIsChainable: function() { with(this) {
|
||||
testObserveAndStopObservingAreChainable: function() { with(this) {
|
||||
var span = $("span"), observer = function() { };
|
||||
span.observe("somethingHappened", observer);
|
||||
|
||||
assertEqual(span, span.observe("somethingHappened", observer));
|
||||
assertEqual(span, span.stopObserving("somethingHappened", observer));
|
||||
|
||||
span.observe("somethingHappened", observer);
|
||||
assertEqual(span, span.stopObserving("somethingHappened"));
|
||||
|
||||
span.observe("somethingHappened", observer);
|
||||
assertEqual(span, span.stopObserving());
|
||||
assertEqual(span, span.stopObserving()); // assert it again, after there are no observers
|
||||
|
||||
span.observe("somethingHappened", observer);
|
||||
assertEqual(span, span.observe("somethingHappened", observer)); // try to reuse the same observer
|
||||
span.stopObserving();
|
||||
}},
|
||||
|
||||
testDocumentContentLoadedEventFiresBeforeWindowLoad: function() { with(this) {
|
||||
|
Loading…
Reference in New Issue
Block a user