Skip to content

Commit bc42238

Browse files
committed
Core: Remove unused removeAttrs method
jQuery Core supports removing space-separated attributes since 1.7, and its not used in the plugin anyway. Fixes jquery-validation#1124
1 parent f33690b commit bc42238

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/core.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,7 @@ $.extend($.fn, {
107107
}
108108
return valid;
109109
},
110-
// attributes: space separated list of attributes to retrieve and remove
111-
removeAttrs: function( attributes ) {
112-
var result = {},
113-
$element = this;
114-
$.each( attributes.split( /\s/ ), function( index, value ) {
115-
result[ value ] = $element.attr( value );
116-
$element.removeAttr( value );
117-
});
118-
return result;
119-
},
110+
120111
// http://jqueryvalidation.org/rules/
121112
rules: function( command, argument ) {
122113
var element = this[ 0 ],

test/rules.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,19 @@ test("rules(), add and remove", function() {
217217
return false;
218218
}, "");
219219
$("#v2").validate();
220-
var removedAttrs = $("#v2-i5").removeClass("required").removeAttrs("minlength maxlength");
220+
$("#v2-i5").removeClass("required").removeAttr("minlength maxlength");
221221
deepEqual( $("#v2-i5").rules(), { customMethod1: "123" });
222222

223-
$("#v2-i5").addClass("required").attr(removedAttrs);
223+
$("#v2-i5").addClass("required").attr({
224+
minlength: 2,
225+
maxlength: 5
226+
});
224227
deepEqual( $("#v2-i5").rules(), { required: true, minlength: 2, maxlength: 5, customMethod1: "123" });
225228

226229
$("#v2-i5").addClass("email").attr({ min: 5 });
227230
deepEqual( $("#v2-i5").rules(), { required: true, email: true, minlength: 2, maxlength: 5, min: 5, customMethod1: "123" });
228231

229-
$("#v2-i5").removeClass("required email").removeAttrs("minlength maxlength customMethod1 min");
232+
$("#v2-i5").removeClass("required email").removeAttr("minlength maxlength customMethod1 min");
230233
deepEqual( $("#v2-i5").rules(), {});
231234

232235
delete $.validator.methods.customMethod1;

0 commit comments

Comments
 (0)