On Sep 12, 11:44 am, achernin <[EMAIL PROTECTED]> wrote: > 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. look at this: > > var elements = $(form).getElements().findAll(function(element) { > return 'hidden' != element.type && !element.disabled; > }); > > so, our solution is to rewrite focusFirstElement like this: > > focusFirstElement: function(form) { > form = $(form); > var element = Form.findFirstElement(form); > if(!Object.isUndefined(element)) > element.activate(); > return form; > }, > > What do you think?
Good catch. I think there's no need for `isUndefined`: focusFirstElement: function(form) { form = $(form); var element = form.findFirstElement(); element && element.activate(); return form; } Could you please file a bug report. Thank you. > > Regards, > Alexander Chernin, Naumen comp. -- kangax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---