Skip to content

Commit ee9e85b

Browse files
ENGCOM-5994: Fix #22747 - JavaScript modules contain unnecessary define checks #24833
- Merge Pull Request #24833 from Bartlomiejsz/magento2:feature/fix_22747_javascript_modules_unnecessary_define_checks - Merged commits: 1. 024c101
2 parents d816d66 + 024c101 commit ee9e85b

File tree

25 files changed

+159
-354
lines changed

25 files changed

+159
-354
lines changed

app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
(function (factory) {
7-
if (typeof define === 'function' && define.amd) {
8-
define([
9-
'jquery',
10-
'mage/backend/validation',
11-
'prototype'
12-
], factory);
13-
} else {
14-
factory(jQuery);
15-
}
16-
}(function (jQuery) {
17-
6+
define([
7+
'jquery',
8+
'mage/backend/validation',
9+
'prototype'
10+
], function (jQuery) {
1811
window.directPost = Class.create();
1912
directPost.prototype = {
2013
initialize: function (methodCode, iframeId, controller, orderSaveUrl, cgiUrl, nativeAction) {
@@ -349,4 +342,4 @@
349342
}
350343
}
351344
};
352-
}));
345+
});

app/code/Magento/Backend/view/adminhtml/web/js/translate.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44
*/
55

66
/* eslint-disable strict */
7-
(function (factory) {
8-
if (typeof define === 'function' && define.amd) {
9-
define([
10-
'jquery',
11-
'mage/mage'
12-
], factory);
13-
} else {
14-
factory(jQuery);
15-
}
16-
}(function ($) {
7+
define([
8+
'jquery',
9+
'mage/mage'
10+
], function ($) {
1711
$.extend(true, $, {
1812
mage: {
1913
translate: (function () {
@@ -51,4 +45,4 @@
5145
$.mage.__ = $.proxy($.mage.translate.translate, $.mage.translate);
5246

5347
return $.mage.__;
54-
}));
48+
});

app/code/Magento/Catalog/view/frontend/web/js/gallery.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,10 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
(function (factory) {
7-
'use strict';
8-
9-
if (typeof define === 'function' && define.amd) {
10-
define([
11-
'jquery',
12-
'jquery-ui-modules/widget'
13-
], factory);
14-
} else {
15-
factory(jQuery);
16-
}
17-
}(function ($) {
6+
define([
7+
'jquery',
8+
'jquery-ui-modules/widget'
9+
], function ($) {
1810
'use strict';
1911

2012
$.widget('mage.gallery', {
@@ -49,4 +41,4 @@
4941
});
5042

5143
return $.mage.gallery;
52-
}));
44+
});

app/code/Magento/Catalog/view/frontend/web/product/view/validation.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,11 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
(function (factory) {
7-
'use strict';
8-
9-
if (typeof define === 'function' && define.amd) {
10-
define([
11-
'jquery',
12-
'jquery-ui-modules/widget',
13-
'mage/validation/validation'
14-
], factory);
15-
} else {
16-
factory(jQuery);
17-
}
18-
}(function ($) {
6+
define([
7+
'jquery',
8+
'jquery-ui-modules/widget',
9+
'mage/validation/validation'
10+
], function ($) {
1911
'use strict';
2012

2113
$.widget('mage.validation', $.mage.validation, {
@@ -97,4 +89,4 @@
9789
});
9890

9991
return $.mage.validation;
100-
}));
92+
});

app/code/Magento/Payment/view/base/web/js/model/credit-card-validation/validator.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,15 @@
44
*/
55

66
/* @api */
7-
(function (factory) {
8-
'use strict';
9-
10-
if (typeof define === 'function' && define.amd) {
11-
define([
12-
'jquery',
13-
'Magento_Payment/js/model/credit-card-validation/cvv-validator',
14-
'Magento_Payment/js/model/credit-card-validation/credit-card-number-validator',
15-
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-year-validator',
16-
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-month-validator',
17-
'Magento_Payment/js/model/credit-card-validation/credit-card-data',
18-
'mage/translate'
19-
], factory);
20-
} else {
21-
factory(jQuery);
22-
}
23-
}(function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) {
7+
define([
8+
'jquery',
9+
'Magento_Payment/js/model/credit-card-validation/cvv-validator',
10+
'Magento_Payment/js/model/credit-card-validation/credit-card-number-validator',
11+
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-year-validator',
12+
'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-month-validator',
13+
'Magento_Payment/js/model/credit-card-validation/credit-card-data',
14+
'mage/translate'
15+
], function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) {
2416
'use strict';
2517

2618
$('.payment-method-content input[type="number"]').on('keyup', function () {
@@ -111,4 +103,4 @@
111103
rule.unshift(i);
112104
$.validator.addMethod.apply($.validator, rule);
113105
});
114-
}));
106+
});

lib/web/mage/backend/button.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,10 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
(function (factory) {
7-
'use strict';
8-
9-
if (typeof define === 'function' && define.amd) {
10-
define([
11-
'jquery',
12-
'jquery/ui'
13-
], factory);
14-
} else {
15-
factory(jQuery);
16-
}
17-
}(function ($) {
6+
define([
7+
'jquery',
8+
'jquery/ui'
9+
], function ($) {
1810
'use strict';
1911

2012
$.widget('ui.button', $.ui.button, {
@@ -58,4 +50,4 @@
5850
});
5951

6052
return $.ui.button;
61-
}));
53+
});

lib/web/mage/backend/form.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,10 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5-
(function (factory) {
6-
'use strict';
7-
8-
if (typeof define === 'function' && define.amd) {
9-
define([
10-
'jquery',
11-
'jquery/ui'
12-
], factory);
13-
} else {
14-
factory(jQuery);
15-
}
16-
}(function ($) {
5+
define([
6+
'jquery',
7+
'jquery/ui'
8+
], function ($) {
179
'use strict';
1810

1911
$.widget('mage.form', {
@@ -209,4 +201,4 @@
209201
});
210202

211203
return $.mage.form;
212-
}));
204+
});

lib/web/mage/backend/menu.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,10 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
(function (factory) {
7-
'use strict';
8-
9-
if (typeof define === 'function' && define.amd) {
10-
define([
11-
'jquery',
12-
'jquery/ui'
13-
], factory);
14-
} else {
15-
factory(jQuery);
16-
}
17-
}(function ($) {
6+
define([
7+
'jquery',
8+
'jquery/ui'
9+
], function ($) {
1810
'use strict';
1911

2012
$.widget('mage.menu', {
@@ -784,4 +776,4 @@
784776
});
785777

786778
return $.mage.menu;
787-
}));
779+
});

lib/web/mage/backend/suggest.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,14 @@
33
* See COPYING.txt for license details.
44
*/
55

6-
(function (root, factory) {
7-
'use strict';
8-
9-
if (typeof define === 'function' && define.amd) {
10-
define([
11-
'jquery',
12-
'mage/template',
13-
'mage/mage',
14-
'jquery/ui',
15-
'mage/backend/menu',
16-
'mage/translate'
17-
], factory);
18-
} else {
19-
factory(root.jQuery, root.mageTemplate);
20-
}
21-
}(this, function ($, mageTemplate) {
6+
define([
7+
'jquery',
8+
'mage/template',
9+
'mage/mage',
10+
'jquery/ui',
11+
'mage/backend/menu',
12+
'mage/translate'
13+
], function ($, mageTemplate) {
2214
'use strict';
2315

2416
/**
@@ -1196,4 +1188,4 @@
11961188
});
11971189

11981190
return $.mage.suggest;
1199-
}));
1191+
});

lib/web/mage/backend/tabs.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,10 @@
44
*/
55

66
/* global FORM_KEY */
7-
(function (factory) {
8-
'use strict';
9-
10-
if (typeof define === 'function' && define.amd) {
11-
define([
12-
'jquery',
13-
'jquery/ui'
14-
], factory);
15-
} else {
16-
factory(jQuery);
17-
}
18-
}(function ($) {
7+
define([
8+
'jquery',
9+
'jquery/ui'
10+
], function ($) {
1911
'use strict';
2012

2113
var rhash, isLocal;
@@ -423,4 +415,4 @@
423415
});
424416

425417
return $.mage.tabs;
426-
}));
418+
});

0 commit comments

Comments
 (0)