Skip to content

Commit c37fc3e

Browse files
committed
Amend flatten function to accomodate for a bugg in UnderscoreJS.
using .each on an object with a property called length will break UnderscoreJS
1 parent dd7e38b commit c37fc3e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/web/mage/utils/objects.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,18 @@ define([
148148
separator = separator || '.';
149149
result = result || {};
150150

151-
_.each(data, function (node, name) {
151+
if(!data) {
152+
return result;
153+
}
154+
155+
// UnderscoreJS each breaks when an object has a length property so we use Object.keys
156+
_.each(Object.keys(data), function (name) {
157+
var node = data[name];
158+
159+
if ({}.toString.call(node) === '[object Function]') {
160+
return;
161+
}
162+
152163
if (parent) {
153164
name = parent + separator + name;
154165
}
@@ -436,3 +447,4 @@ define([
436447
}
437448
};
438449
});
450+

0 commit comments

Comments
 (0)