#1140 new

Return value of event.stop()

Reported by Johan | September 16th, 2010 @ 03:13 PM

I've posted this some time ago on the mailing list but never got to the point to submit a patch.

Original post:

Hello everyone,

I was just checking out some of my code to see if I could optimize it and I
noticed that in event handlers the event.stop() method has to be
called separately from all other code. Something I like about prototype is
that a lot of methods can be chained like the Element methods
(e.addClassName('bla').insert(foo).toggle().observe('click', bar).......).

But instead of returning the event, event.stop() returns 'undefined' making
it impossible to do something like this:

var e = event.stop().findElement('a');
and forcing me to use 2 lines:
var e = event.findElement('a');
I've added 'return event;' at the bottom of the stop method in Event.Methods
and it works perfectly (in FireFox, haven't tested in other browsers). Is it
possible to make this small change? Or is there a reason why the event isn't

Johan Arensman

I've added a patch in which I've added return event; and edited the comments above Event.stop().

I wasn't sure how to add a test for this, but I made a simple testpage and attached it to this ticket.

I hope this very simple fix makes it :-)

Johan Arensman

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket