Skip to content

Commit a4dee84

Browse files
authored
Merge pull request #33609 from mrtuvn/update-underscore-latest
Update underscore to latest version
2 parents 83d1b87 + 2c52a3c commit a4dee84

File tree

7 files changed

+2026
-1524
lines changed

7 files changed

+2026
-1524
lines changed

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ define([
120120
storage.remove(sectionName);
121121
sectionDataIds = $.cookieStorage.get('section_data_ids') || {};
122122
_.each(sectionDataIds, function (data, name) {
123-
if (name != sectionName) { //eslint-disable-line eqeqeq
123+
if (name !== sectionName) {
124124
newSectionDataIds[name] = data;
125125
}
126126
});
@@ -266,7 +266,7 @@ define([
266266

267267
if (typeof sectionData === 'undefined' ||
268268
typeof sectionData === 'object' &&
269-
cookieSectionTimestamp != sectionData['data_id'] //eslint-disable-line
269+
cookieSectionTimestamp !== sectionData['data_id']
270270
) {
271271
expiredSectionNames.push(sectionName);
272272
}

app/code/Magento/Customer/view/frontend/web/js/section-config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ define(['underscore'], function (_) {
3232
/**
3333
* Returns a list of sections which should be invalidated for given URL.
3434
* @param {String} url - URL which was requested.
35-
* @return {Array} - List of sections to invalidate.
35+
* @return {Object} - List of sections to invalidate.
3636
*/
3737
getAffectedSections: function (url) {
3838
var route = canonize(url),
@@ -55,8 +55,8 @@ define(['underscore'], function (_) {
5555

5656
/**
5757
* Filters the list of given sections to the ones defined as client side.
58-
* @param {Array} allSections - List of sections to check.
59-
* @return {Array} - List of filtered sections.
58+
* @param {Object} allSections - List of sections to check.
59+
* @return {Object} - List of filtered sections.
6060
*/
6161
filterClientSideSections: function (allSections) {
6262
return _.difference(allSections, clientSideSections);

app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
/* eslint-disable no-undef */
66
define([
77
'jquery',
8+
'underscore',
89
'Magento_Ui/js/grid/columns/column',
910
'Magento_Ui/js/lib/key-codes'
10-
], function ($, Column, keyCodes) {
11+
], function ($, _, Column, keyCodes) {
1112
'use strict';
1213

1314
return Column.extend({

dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/customer-data.test.js

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

6-
/* global _ */
76
/* eslint max-nested-callbacks: 0 */
87
/* jscs:disable jsDoc*/
98

109
define([
10+
'underscore',
1111
'squire',
1212
'jquery',
1313
'Magento_Customer/js/section-config',
1414
'Magento_Customer/js/customer-data',
1515
'jquery/jquery-storageapi'
16-
], function (Squire, $, sectionConfig, customerData) {
16+
], function (_, Squire, $, sectionConfig, customerData) {
1717
'use strict';
1818

1919
var injector = new Squire(),
@@ -98,9 +98,6 @@ define([
9898
}
9999

100100
describe('Magento_Customer/js/customer-data', function () {
101-
102-
var _;
103-
104101
beforeAll(function () {
105102
clearLocalStorage();
106103
});
@@ -401,7 +398,6 @@ define([
401398
}
402399
};
403400
};
404-
405401
expect(parameters).toEqual(jasmine.objectContaining({
406402
sections: 'section'
407403
}));
@@ -410,7 +406,6 @@ define([
410406
});
411407

412408
result = obj.reload(['section'], true);
413-
414409
expect(result).toEqual(jasmine.objectContaining({
415410
responseJSON: {
416411
section: {}
@@ -422,7 +417,6 @@ define([
422417
var result;
423418

424419
spyOn(sectionConfig, 'filterClientSideSections').and.returnValue(['cart,customer,messages']);
425-
426420
$.getJSON = jasmine.createSpy().and.callFake(function (url, parameters) {
427421
var deferred = $.Deferred();
428422

@@ -448,7 +442,6 @@ define([
448442
});
449443

450444
result = obj.reload(['cart', 'customer', 'messages'], true);
451-
452445
expect(result).toEqual(jasmine.objectContaining({
453446
responseJSON: {
454447
cart: {},
@@ -457,7 +450,7 @@ define([
457450
}
458451
}));
459452
});
460-
//
453+
461454
it('Check it returns all sections when passed wildcard string', function () {
462455
var result;
463456

@@ -486,7 +479,6 @@ define([
486479
});
487480

488481
result = obj.reload('*', true);
489-
490482
expect($.getJSON).toHaveBeenCalled();
491483
expect(result).toEqual(jasmine.objectContaining({
492484
responseJSON: {

lib/web/mage/utils/main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ define(function (require) {
66
'use strict';
77

88
var utils = {},
9-
_ = require('underscore');
9+
_ = require('underscore'),
10+
root = typeof self == 'object' && self.self === self && self ||
11+
typeof global == 'object' && global.global === global && global ||
12+
Function('return this')() || {};
13+
14+
root._ = _;
1015

1116
return _.extend(
1217
utils,

0 commit comments

Comments
 (0)