[Prototype-core] Return value of Event.stop()

21 views
Skip to first unread message

Johan Arensman

unread,
May 25, 2010, 6:01:42 AM5/25/10
to prototy...@googlegroups.com
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:

event.stop();
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 returned?

Greetings,
 Johan Arensman

--
You received this message because you are subscribed to the Google Groups "Prototype: Core" group.
To post to this group, send email to prototy...@googlegroups.com
To unsubscribe from this group, send email to prototype-cor...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en

Tobie Langel

unread,
May 25, 2010, 3:35:56 PM5/25/10
to Prototype: Core
Great idea.

Would you mind submitting a patch with tests?

Thanks,

Tobie

T.J. Crowder

unread,
May 26, 2010, 7:08:08 AM5/26/10
to Prototype: Core
+1 on the idea, seems like a winner to me.

-- T.J.

Reply all
Reply to author
Forward
0 new messages