#341 ✓resolved
achernin

focusFirstElement() fails on empty forms

Reported by achernin | September 15th, 2008 @ 08:57 AM | in 1.7

prototype.js, Version: '1.6.0.2', Line 3462

focusFirstElement: function(form) {

form = $(form);
form.findFirstElement().activate();
return form;

},

this code is unsafe. findFirstElement() function returns empty value, if form has no elements.

proposed solution is

focusFirstElement: function(form) {

form = $(form);
var element = form.findFirstElement();
element && element.activate();
return form;

}

look at this discussion

http://groups.google.com/group/p...

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

Referenced by

Pages