File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
packages/svelte/src/reactivity Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,12 @@ function get_self() {
29
29
return this ;
30
30
}
31
31
32
+ let inited = false ;
33
+
32
34
/**
33
35
* @template T
34
36
*/
35
37
export class ReactiveSet extends Set {
36
- static #inited = false ;
37
-
38
38
/** @type {Map<T, import('#client').Source<boolean>> } */
39
39
#sources = new Map ( ) ;
40
40
#version = source ( 0 ) ;
@@ -55,24 +55,23 @@ export class ReactiveSet extends Set {
55
55
}
56
56
}
57
57
58
- this . #init( ) ;
58
+ if ( ! inited ) this . #init( ) ;
59
59
}
60
60
61
61
// We init as part of the first instance so that we can treeshake this class
62
62
#init( ) {
63
- if ( ! ReactiveSet . #inited) {
64
- ReactiveSet . #inited = true ;
65
- const proto = ReactiveSet . prototype ;
66
- const set_proto = Set . prototype ;
63
+ inited = true ;
67
64
68
- for ( const method of read ) {
65
+ const proto = ReactiveSet . prototype ;
66
+ const set_proto = Set . prototype ;
67
+
68
+ for ( const method of read ) {
69
+ // @ts -ignore
70
+ proto [ method ] = function ( ...v ) {
71
+ get ( this . #version) ;
69
72
// @ts -ignore
70
- proto [ method ] = function ( ...v ) {
71
- get ( this . #version) ;
72
- // @ts -ignore
73
- return set_proto [ method ] . apply ( this , v ) ;
74
- } ;
75
- }
73
+ return set_proto [ method ] . apply ( this , v ) ;
74
+ } ;
76
75
}
77
76
}
78
77
You can’t perform that action at this time.
0 commit comments