Skip to content

Commit 50141a9

Browse files
authored
fix: improve deepUpdate logic for array item matching (#7507)
* fix(repl): improve deepUpdate logic for array item matching
1 parent a14b9ff commit 50141a9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/docs/src/repl/repl-output-update.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ const deepUpdate = (prev: any, next: any) => {
1313
}
1414
if (Array.isArray(prev)) {
1515
for (const item of prev) {
16-
if (!next.includes(item)) {
16+
// can't use Object as a matcher
17+
// because it will be a different object
18+
// so we need to use the path or code
19+
20+
if (
21+
next.some((nextItem: any) => (nextItem.path || nextItem.code) === (item.path || item.code))
22+
) {
1723
prev.splice(prev.indexOf(item), 1);
1824
}
1925
}
@@ -33,6 +39,7 @@ export const updateReplOutput = async (store: ReplStore, result: ReplResult) =>
3339
if (store.html !== result.html) {
3440
store.html = result.html;
3541
}
42+
3643
deepUpdate(store.transformedModules, result.transformedModules);
3744
deepUpdate(store.clientBundles, result.clientBundles);
3845
deepUpdate(store.ssrModules, result.ssrModules);

0 commit comments

Comments
 (0)