Skip to content

Commit ea283b7

Browse files
committed
fix(array): copy atomics from source array (Automattic#7889)
1 parent 276b8e2 commit ea283b7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/types/array.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ function MongooseArray(values, path, doc) {
3939
// TODO: replace this with `new CoreMongooseArray().concat()` when we remove
4040
// support for node 4.x and 5.x, see https://i.imgur.com/UAAHk4S.png
4141
const arr = new CoreMongooseArray();
42+
arr[arrayAtomicsSymbol] = {};
4243

4344
if (Array.isArray(values)) {
4445
values.forEach(v => { arr.push(v); });
46+
47+
arr[arrayAtomicsSymbol] = values[arrayAtomicsSymbol] || {};
4548
}
4649

4750
const keysMA = Object.keys(MongooseArray.mixin);
@@ -52,7 +55,6 @@ function MongooseArray(values, path, doc) {
5255

5356
arr[arrayPathSymbol] = path;
5457
arr.validators = [];
55-
arr[arrayAtomicsSymbol] = {};
5658
arr[arraySchemaSymbol] = void 0;
5759
if (util.inspect.custom) {
5860
arr[util.inspect.custom] = arr.inspect;

0 commit comments

Comments
 (0)