Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

The methods focus() and blur() should be applied to all elements #543

Closed
wants to merge 1 commit into from

2 participants

@juhovh

Consider the case $('input').blur() where $('input') returns two elements and the second one is selected. The current code only blurs the first one and the second one stays selected. Works OK in jQuery but fails in Zepto.

@mislav mislav closed this pull request from a commit
@juhovh juhovh apply focus() and blur() to all elements in collection
This ensures that a focused element gets blurred even if it's not the
first element in the collection.

Closes #543
85c8a84
@mislav mislav closed this in 85c8a84
@lopper lopper referenced this pull request from a commit in buddydvd/zepto
@juhovh juhovh apply focus() and blur() to all elements in collection
This ensures that a focused element gets blurred even if it's not the
first element in the collection.

Closes #543
78f6edd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 6, 2012
  1. @juhovh
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/event.js
View
4 src/event.js
@@ -209,7 +209,9 @@
;['focus', 'blur'].forEach(function(name) {
$.fn[name] = function(callback) {
if (callback) this.bind(name, callback)
- else if (this.length) try { this.get(0)[name]() } catch(e){}
+ else this.forEach(function(element) {
+ try { element[name]() } catch(e){}
+ })
return this
}
})
Something went wrong with that request. Please try again.