Skip to content

Commit 98fbc5f

Browse files
authored
Core: remove pending class from fields with an aborted request (jquery-validation#2436)
Ref jquery-validation#2434 Ref jquery-validation#2435 Co-authored-by: Sylvain Monné <sylvain@monne.me>
1 parent 980087a commit 98fbc5f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/core.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,7 @@ $.extend( $.validator, {
11521152
}
11531153

11541154
delete this.pending[ element.name ];
1155+
$( element ).removeClass( this.settings.pendingClass );
11551156
}
11561157
},
11571158

test/methods.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,19 @@ QUnit.test( "Fix #2434: race condition in remote validation rules", function( as
822822

823823
e.val( "Peter" );
824824
v.element( e );
825+
assert.equal( e.hasClass( "error" ), false, "Field 'username' should not have the error class" );
826+
assert.equal( e.hasClass( "pending" ), true, "field 'username' should have the pending class" );
825827

826828
e.val( "" );
827829
v.element( e );
830+
assert.equal( v.errorList[ 0 ].message, "This field is required." );
831+
assert.equal( e.hasClass( "error" ), true, "Field 'username' should have the error class" );
832+
assert.equal( e.hasClass( "pending" ), false, "field 'username' should not have the pending class" );
833+
828834
setTimeout( function() {
829835
assert.equal( v.errorList[ 0 ].message, "This field is required." );
836+
assert.equal( e.hasClass( "error" ), true, "Field 'username' should have the error class" );
837+
assert.equal( e.hasClass( "pending" ), false, "field 'username' should not have the pending class" );
830838
done1();
831839
} );
832840
} );

0 commit comments

Comments
 (0)