Skip to content

Commit ee888ca

Browse files
committed
use underscore find
1 parent f22ead8 commit ee888ca

File tree

2 files changed

+3
-42
lines changed

2 files changed

+3
-42
lines changed

app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ define([
140140

141141
$.each(queryParams, $.proxy(function (key, value) {
142142
if (this.options.spConfig.attributes[key] !== undefined &&
143-
this.options.spConfig.attributes[key].options.find(function (element) {
143+
_.find(this.options.spConfig.attributes[key].options, function (element) {
144144
return element.id === value;
145145
})) {
146146
this.options.values[key] = value;
@@ -162,7 +162,7 @@ define([
162162
attributeId = element.id.replace(/[a-z]*/, '');
163163

164164
if (this.options.spConfig.attributes[attributeId] !== undefined &&
165-
this.options.spConfig.attributes[attributeId].options.find(function (optionElement) {
165+
_.find(this.options.spConfig.attributes[attributeId].options, function (optionElement) {
166166
return optionElement.id === element.value;
167167
})) {
168168
this.options.values[attributeId] = element.value;

dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/frontend/js/configurable.test.js

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,6 @@ define([
2020
selectElement = $(option);
2121

2222
beforeEach(function () {
23-
//remove this lines when jasmine version will be upgraded
24-
if (!Array.prototype.find) {
25-
Object.defineProperty(Array.prototype, 'find', {//eslint-disable-line
26-
enumerable: false,
27-
configurable: true,
28-
writable: true,
29-
30-
/**
31-
* Find method
32-
*/
33-
value: function (predicate) {
34-
var list = Object(this),
35-
length = list.length >>> 0,
36-
thisArg = arguments[1],
37-
value,
38-
i;
39-
40-
if (this == null) {
41-
throw new TypeError('Array.prototype.find called on null or undefined');
42-
}
43-
44-
if (typeof predicate !== 'function') {
45-
throw new TypeError('predicate must be a function');
46-
}
47-
48-
for (i = 0; i < length; i++) {
49-
if (i in list) {
50-
value = list[i];
51-
52-
if (predicate.call(thisArg, value, i, list)) {//eslint-disable-line
53-
return value;
54-
}
55-
}
56-
}
57-
58-
return undefined;
59-
}
60-
});
61-
}
6223
widget = new Configurable();
6324
widget.options = {
6425
spConfig: {
@@ -98,7 +59,7 @@ define([
9859
expect(widget.options.values.size).toBe('2');
9960
});
10061

101-
it('check that attribute value is not set id provided option does not exists', function () {
62+
it('check that attribute value is not set if provided option does not exists', function () {
10263
expect($.mage.configurable).toBeDefined();
10364
widget._parseQueryParams('size=10');
10465
widget._fillSelect(selectElement[0]);

0 commit comments

Comments
 (0)