Skip to content

Commit 8529944

Browse files
author
Eric Claeren
committed
24070 - Optimized code and fix linting errors for validate-store.js.
1 parent bf071ff commit 8529944

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app/code/Magento/Backend/view/adminhtml/web/js/validate-store.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,16 @@ define([
4747
_saveHandler: function (form) {
4848
var formData = {},
4949
requestData = {},
50+
counts = {},
5051
options = $.data(form, 'validator').settings;
5152

5253
if ($(form).validation('isValid')) {
53-
var counts = {};
5454
$.each($(form).serializeArray(), function () {
55-
var name = this.name;
56-
counts[name] = (counts[name] || 0) + 1;
57-
if (formData[name]) {
58-
var replacement = '[' + (counts[name] - 1) + ']';
59-
name = name.replace(new RegExp(/\[\]$/g), replacement);
55+
counts[this.name] = (counts[this.name] || 0) + 1;
56+
if (formData[this.name]) {
57+
this.name = this.name.replace(new RegExp(/\[\]$/g), '[' + (counts[this.name] - 1) + ']');
6058
}
61-
formData[name] = this.value || '';
59+
formData[this.name] = this.value || '';
6260
});
6361

6462
requestData = {

0 commit comments

Comments
 (0)