Skip to content

Commit 1212a97

Browse files
committed
Bugfixes for compability with jQuery 1.4.2, while maintaining backwards-compability
1 parent 7c47463 commit 1212a97

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

jquery.validate.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,12 @@ $.extend($.validator, {
409409
focusInvalid: function() {
410410
if( this.settings.focusInvalid ) {
411411
try {
412-
$(this.findLastActive() || this.errorList.length && this.errorList[0].element || []).filter(":visible").focus();
412+
$(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
413+
.filter(":visible")
414+
.focus()
415+
// manually trigger validatefocusin event in IE, where focusin isn't a special event triggered by a triggered focus event
416+
// without it, focusin handler isn't called, findLastActive won't have anything to find
417+
.trigger("validatefocusin");
413418
} catch(e) {
414419
// ignore IE throwing errors when focusing hidden elements
415420
}
@@ -1101,8 +1106,6 @@ $.format = $.validator.format;
11011106

11021107
// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
11031108
// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
1104-
1105-
// provides triggerEvent(type: String, target: Element) to trigger delegated events
11061109
;(function($) {
11071110
$.each({
11081111
focus: 'validatefocusin',
@@ -1111,19 +1114,23 @@ $.format = $.validator.format;
11111114
$.event.special[fix] = {
11121115
setup:function() {
11131116
if ( $.browser.msie ) return false;
1114-
this.addEventListener( original, $.event.special[fix].handler, true );
1117+
this.addEventListener( original, handler, true );
11151118
},
11161119
teardown:function() {
11171120
if ( $.browser.msie ) return false;
1118-
this.removeEventListener( original,
1119-
$.event.special[fix].handler, true );
1121+
this.removeEventListener( original, handler, true );
11201122
},
11211123
handler: function(e) {
11221124
arguments[0] = $.event.fix(e);
11231125
arguments[0].type = fix;
11241126
return $.event.handle.apply(this, arguments);
11251127
}
11261128
};
1129+
function handler(e) {
1130+
e = $.event.fix(e);
1131+
e.type = fix;
1132+
return $.event.handle.call(this, e);
1133+
}
11271134
});
11281135
$.extend($.fn, {
11291136
validateDelegate: function(delegate, type, handler) {

0 commit comments

Comments
 (0)