Skip to content

Commit 88c685e

Browse files
committed
Update underscore to version 1.13.1
1 parent 5812ec7 commit 88c685e

File tree

4 files changed

+2047
-1540
lines changed

4 files changed

+2047
-1540
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ define([
9898
sectionNames = sectionConfig.filterClientSideSections(sectionNames);
9999
parameters = _.isArray(sectionNames) && sectionNames.indexOf('*') < 0 ? {
100100
sections: sectionNames.join(',')
101-
} : [];
102-
parameters['force_new_section_timestamp'] = forceNewSectionTimestamp;
101+
} : {};
102+
parameters.force_new_section_timestamp = forceNewSectionTimestamp;
103103

104104
return $.getJSON(options.sectionLoadUrl, parameters).fail(function (jqXHR) {
105105
throw new Error(jqXHR);
@@ -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
});
@@ -179,7 +179,7 @@ define([
179179
sectionDataIds = $.cookieStorage.get('section_data_ids') || {};
180180

181181
_.each(sections, function (sectionData, sectionName) {
182-
sectionId = sectionData['data_id'];
182+
sectionId = sectionData.data_id;
183183
sectionDataIds[sectionName] = sectionId;
184184
storage.set(sectionName, sectionData);
185185
storageInvalidation.remove(sectionName);
@@ -255,7 +255,7 @@ define([
255255
_.each(options.expirableSectionNames, function (sectionName) {
256256
sectionData = storage.get(sectionName);
257257

258-
if (typeof sectionData === 'object' && sectionData['data_id'] + sectionLifetime <= currentTimestamp) {
258+
if (typeof sectionData === 'object' && sectionData.data_id + sectionLifetime <= currentTimestamp) {
259259
expiredSectionNames.push(sectionName);
260260
}
261261
});
@@ -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/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: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* See COPYING.txt for license details.
44
*/
55

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

@@ -46,6 +45,27 @@ define([
4645
]
4746
};
4847

48+
var _;
49+
50+
beforeEach(function (done) {
51+
injector.require([
52+
'underscore',
53+
'Magento_Customer/js/customer-data'
54+
], function (underscore, Constr) {
55+
_ = underscore;
56+
obj = Constr;
57+
done();
58+
});
59+
});
60+
61+
afterEach(function () {
62+
try {
63+
injector.clean();
64+
injector.remove();
65+
} catch (e) {
66+
}
67+
});
68+
4969
function init(config) {
5070
var defaultConfig = {
5171
sectionLoadUrl: 'http://localhost/customer/section/load/',
@@ -63,7 +83,7 @@ define([
6383
sectionDataIds = {};
6484

6585
_.each(sections, function (sectionData, sectionName) {
66-
sectionDataIds[sectionName] = sectionData['data_id'];
86+
sectionDataIds[sectionName] = sectionData.data_id;
6787

6888
if (typeof sectionData.content !== 'undefined') {
6989
mageCacheStorage[sectionName] = sectionData;
@@ -89,34 +109,22 @@ define([
89109
);
90110
}
91111

92-
function clearLocalStorage() {
93-
$.cookieStorage.set('section_data_ids', {});
94-
95-
if (window.localStorage) {
96-
window.localStorage.clear();
97-
}
98-
}
99-
100112
describe('Magento_Customer/js/customer-data', function () {
113+
function clearLocalStorage() {
114+
$.cookieStorage.set('section_data_ids', {});
101115

102-
var _;
116+
if (window.localStorage) {
117+
window.localStorage.clear();
118+
}
119+
}
103120

104121
beforeAll(function () {
105122
clearLocalStorage();
106123
});
107124

108-
beforeEach(function (done) {
125+
beforeEach(function () {
109126
originalGetJSON = $.getJSON;
110127
sectionConfig['Magento_Customer/js/section-config'](sectionConfigSettings);
111-
112-
injector.require([
113-
'underscore',
114-
'Magento_Customer/js/customer-data'
115-
], function (underscore, Constr) {
116-
_ = underscore;
117-
obj = Constr;
118-
done();
119-
});
120128
});
121129

122130
afterEach(function () {
@@ -401,16 +409,13 @@ define([
401409
}
402410
};
403411
};
404-
405412
expect(parameters).toEqual(jasmine.objectContaining({
406413
sections: 'section'
407414
}));
408-
409415
return deferred.promise();
410416
});
411417

412418
result = obj.reload(['section'], true);
413-
414419
expect(result).toEqual(jasmine.objectContaining({
415420
responseJSON: {
416421
section: {}
@@ -422,7 +427,6 @@ define([
422427
var result;
423428

424429
spyOn(sectionConfig, 'filterClientSideSections').and.returnValue(['cart,customer,messages']);
425-
426430
$.getJSON = jasmine.createSpy().and.callFake(function (url, parameters) {
427431
var deferred = $.Deferred();
428432

@@ -448,7 +452,6 @@ define([
448452
});
449453

450454
result = obj.reload(['cart', 'customer', 'messages'], true);
451-
452455
expect(result).toEqual(jasmine.objectContaining({
453456
responseJSON: {
454457
cart: {},
@@ -457,7 +460,7 @@ define([
457460
}
458461
}));
459462
});
460-
//
463+
461464
it('Check it returns all sections when passed wildcard string', function () {
462465
var result;
463466

@@ -486,7 +489,6 @@ define([
486489
});
487490

488491
result = obj.reload('*', true);
489-
490492
expect($.getJSON).toHaveBeenCalled();
491493
expect(result).toEqual(jasmine.objectContaining({
492494
responseJSON: {

0 commit comments

Comments
 (0)