File tree 1 file changed +15
-0
lines changed
packages/svelte/src/internal/client/dev 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,14 @@ import { get_proxied_value } from '../proxy.js';
3
3
4
4
export function init_array_prototype_warnings ( ) {
5
5
const array_prototype = Array . prototype ;
6
+ // The REPL ends up here over and over, and this prevents it from adding more and more patches
7
+ // of the same kind to the prototype, which would slow down everything over time.
8
+ // @ts -expect-error
9
+ const cleanup = Array . __svelte_cleanup ;
10
+ if ( cleanup ) {
11
+ cleanup ( ) ;
12
+ }
13
+
6
14
const { indexOf, lastIndexOf, includes } = array_prototype ;
7
15
8
16
array_prototype . indexOf = function ( item , from_index ) {
@@ -55,6 +63,13 @@ export function init_array_prototype_warnings() {
55
63
56
64
return has ;
57
65
} ;
66
+
67
+ // @ts -expect-error
68
+ Array . __svelte_cleanup = ( ) => {
69
+ array_prototype . indexOf = indexOf ;
70
+ array_prototype . lastIndexOf = lastIndexOf ;
71
+ array_prototype . includes = includes ;
72
+ } ;
58
73
}
59
74
60
75
/**
You can’t perform that action at this time.
0 commit comments