Skip to content

Commit 10d15b0

Browse files
Indrani sonawaneIndrani sonawane
authored andcommitted
Merge remote-tracking branch '37477/improve-product-edit-pages-load-performance' into comm_247beta3
2 parents 968fb3e + fbee733 commit 10d15b0

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

app/code/Magento/Ui/view/base/web/js/lib/view/utils/dom-observer.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ define([
147147
*/
148148
function processAdded(node) {
149149
_.each(watchers.selectors, function (listeners, selector) {
150-
listeners.forEach(function (data) {
150+
for (let data of listeners) {
151151
if (!data.ctx.contains(node) || !$(node, data.ctx).is(selector)) {
152152
return;
153153
}
@@ -157,7 +157,7 @@ define([
157157
} else if (data.type === 'remove') {
158158
addRemovalListener(node, data);
159159
}
160-
});
160+
}
161161
});
162162
}
163163

@@ -170,14 +170,14 @@ define([
170170
var nodeData = getNodeData(node),
171171
listeners = nodeData && nodeData.remove;
172172

173+
173174
if (!listeners) {
174175
return;
175176
}
176177

177-
listeners.forEach(function (data) {
178+
for (let data of listeners) {
178179
trigger(node, data);
179-
});
180-
180+
}
181181
removeNodeData(node);
182182
}
183183

@@ -194,12 +194,12 @@ define([
194194

195195
nodes = _.toArray(nodes).filter(isElementNode);
196196

197-
nodes.forEach(function (node) {
197+
for (let node of nodes) {
198198
result.push(node);
199199

200200
children = extractChildren(node);
201-
result = result.concat(children);
202-
});
201+
result.push(...children);
202+
}
203203

204204
return result;
205205
}
@@ -216,10 +216,10 @@ define([
216216
var removed = [],
217217
added = [];
218218

219-
mutations.forEach(function (record) {
220-
removed = removed.concat(_.toArray(record.removedNodes));
221-
added = added.concat(_.toArray(record.addedNodes));
222-
});
219+
for (let record of mutations) {
220+
removed.push(...record.removedNodes);
221+
added.push(...record.addedNodes);
222+
}
223223

224224
removed = removed.filter(function (node) {
225225
var addIndex = added.indexOf(node),
@@ -285,10 +285,16 @@ define([
285285
var changes;
286286

287287
if (shouldObserveMutations(mutations)) {
288+
let node;
289+
288290
changes = formChangesLists(mutations);
289291

290-
changes.removed.forEach(processRemoved);
291-
changes.added.forEach(processAdded);
292+
for (node of changes.removed) {
293+
processRemoved(node);
294+
}
295+
for (node of changes.added) {
296+
processAdded(node);
297+
}
292298
}
293299
});
294300

@@ -331,10 +337,9 @@ define([
331337

332338
nodes = $(selector, data.ctx).toArray();
333339

334-
nodes.forEach(function (node) {
340+
for (let node of nodes) {
335341
trigger(node, data);
336-
});
337-
342+
}
338343
addSelectorListener(selector, data);
339344
},
340345

@@ -366,9 +371,9 @@ define([
366371
addSelectorListener(selector, data);
367372
}
368373

369-
nodes.forEach(function (node) {
374+
for (let node of nodes) {
370375
addRemovalListener(node, data);
371-
});
376+
}
372377
},
373378

374379
/**

0 commit comments

Comments
 (0)