Skip to content

Commit a3b4ea1

Browse files
committed
fix(documentarray): fix error when modifying array after slice()
Fix #8317
1 parent 203450c commit a3b4ea1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/types/documentarray.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ class CoreDocumentArray extends CoreMongooseArray {
172172
}));
173173
}
174174

175+
slice() {
176+
const arr = super.slice.apply(this, arguments);
177+
arr[arrayParentSymbol] = this[arrayParentSymbol];
178+
arr[arrayPathSymbol] = this[arrayPathSymbol];
179+
180+
return arr;
181+
}
182+
175183
/**
176184
* Wraps [`Array#push`](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/push) with proper change tracking.
177185
*

0 commit comments

Comments
 (0)