ded / bonzo

library agnostic, extensible DOM utility
Other
1.32k stars 137 forks source link

add focus() and blur() to bonzo #54

Closed connor closed 12 years ago

connor commented 12 years ago
connor commented 12 years ago

if you target more than one element, only the last one gets focused, since only one can be focused at a time.

ded commented 12 years ago

you'll want to only focus the first item in the selection. and also for build purposes, edit the file in the src/ directory

connor commented 12 years ago

cool. will fix that tonight and edit my pull request.

connor commented 12 years ago

@ded I figured I should keep the code that iterates over all the selection and blurs it, just for more flexibility. If someone targets a class of inputs, and calls blur() on them, I figure it should blur them all no matter what, not just the first one. However, if they are doing that for focus(), I think it makes sense to focus only the first one.

Anyways - the updated code's there. Let me know if you want me to change anything else!

rvagg commented 12 years ago

You'll probably want a test of some kind in focus() that makes sure you don't get an exception when this.length==0.

connor commented 12 years ago

right. thanks for catching that! just coded up the fix really quick and didn't even consider that. will adjust this and make a new Pull Request!