Skip to content

Commit 5ceb84b

Browse files
committed
fix: cleanup array prototype monkeypatching
1 parent 6f28e41 commit 5ceb84b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/svelte/src/internal/client/dev/equality.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { get_proxied_value } from '../proxy.js';
33

44
export function init_array_prototype_warnings() {
55
const array_prototype = Array.prototype;
6+
// @ts-expect-error
7+
const cleanup = Array.__svelte_cleanup;
8+
if (cleanup) {
9+
cleanup();
10+
}
11+
612
const { indexOf, lastIndexOf, includes } = array_prototype;
713

814
array_prototype.indexOf = function (item, from_index) {
@@ -55,6 +61,13 @@ export function init_array_prototype_warnings() {
5561

5662
return has;
5763
};
64+
65+
// @ts-expect-error
66+
Array.__svelte_cleanup = () => {
67+
array_prototype.indexOf = indexOf;
68+
array_prototype.lastIndexOf = lastIndexOf;
69+
array_prototype.includes = includes;
70+
};
5871
}
5972

6073
/**

0 commit comments

Comments
 (0)