aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2012-11-23 15:03:55 -0500
committerDave Methvin <dave.methvin@gmail.com>2012-11-24 14:44:39 -0500
commitb7ec6ddd45e27b54f3e094172b7eeb6949d4f71b (patch)
treec31c3f529e88cc4e7eb361a55a14a68e2405a673 /src/event.js
parent1fb2f92c357b985a5ba18d0938edd27b5f64d8c3 (diff)
downloadjquery-b7ec6ddd45e27b54f3e094172b7eeb6949d4f71b.tar.gz
jquery-b7ec6ddd45e27b54f3e094172b7eeb6949d4f71b.zip
Fix #12868. Use native focus/blur to get event order right.
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/event.js b/src/event.js
index aeee603f7..e92336a91 100644
--- a/src/event.js
+++ b/src/event.js
@@ -526,16 +526,34 @@ jQuery.event = {
click: {
// For checkbox, fire native event so checked state will be right
trigger: function() {
- if ( jQuery.nodeName( this, "input") && this.type === "checkbox" && this.click ) {
+ if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
this.click();
return false;
}
}
},
focus: {
+ // Fire native event if possible so blur/focus sequence is correct
+ trigger: function() {
+ if ( this !== document.activeElement && this.focus ) {
+ try {
+ this.focus();
+ return false;
+ } catch ( e ) {
+ // IE<9 dies on focus to hidden element (#1486,#12518)
+ // If this happens, let .trigger() run the handlers
+ }
+ }
+ },
delegateType: "focusin"
},
blur: {
+ trigger: function() {
+ if ( this === document.activeElement && this.blur ) {
+ this.blur();
+ return false;
+ }
+ },
delegateType: "focusout"
},