mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Ensure that _.transform checks that object is an object before using it as the accumulator [[Prototype]].
This commit is contained in:
@@ -6945,9 +6945,10 @@
|
||||
if (isArr) {
|
||||
accumulator = [];
|
||||
} else {
|
||||
var ctor = object && object.constructor,
|
||||
proto = ctor && ctor.prototype;
|
||||
|
||||
if (isObject(object)) {
|
||||
var ctor = object.constructor,
|
||||
proto = ctor && ctor.prototype;
|
||||
}
|
||||
accumulator = baseCreate(proto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9404,6 +9404,10 @@
|
||||
ok(_.transform(new Foo) instanceof Foo);
|
||||
});
|
||||
|
||||
test('should check that `object` is an object before using it as the `accumulator` `[[Prototype]]', 1, function() {
|
||||
ok(!(_.transform(1) instanceof Number));
|
||||
});
|
||||
|
||||
_.each({
|
||||
'array': [1, 2, 3],
|
||||
'object': { 'a': 1, 'b': 2, 'c': 3 }
|
||||
|
||||
Reference in New Issue
Block a user