@@ -82,13 +82,12 @@ function push_effect(effect, parent_effect) {
82
82
* @returns {Effect }
83
83
*/
84
84
function create_effect ( type , fn , sync , push = true ) {
85
- var is_root = ( type & ROOT_EFFECT ) !== 0 ;
86
- var parent_effect = active_effect ;
85
+ var parent = active_effect ;
87
86
88
87
if ( DEV ) {
89
88
// Ensure the parent is never an inspect effect
90
- while ( parent_effect !== null && ( parent_effect . f & INSPECT_EFFECT ) !== 0 ) {
91
- parent_effect = parent_effect . parent ;
89
+ while ( parent !== null && ( parent . f & INSPECT_EFFECT ) !== 0 ) {
90
+ parent = parent . parent ;
92
91
}
93
92
}
94
93
@@ -103,7 +102,7 @@ function create_effect(type, fn, sync, push = true) {
103
102
fn,
104
103
last : null ,
105
104
next : null ,
106
- parent : is_root ? null : parent_effect ,
105
+ parent,
107
106
prev : null ,
108
107
teardown : null ,
109
108
transitions : null ,
@@ -136,9 +135,9 @@ function create_effect(type, fn, sync, push = true) {
136
135
effect . teardown === null &&
137
136
( effect . f & ( EFFECT_HAS_DERIVED | BOUNDARY_EFFECT ) ) === 0 ;
138
137
139
- if ( ! inert && ! is_root && push ) {
140
- if ( parent_effect !== null ) {
141
- push_effect ( effect , parent_effect ) ;
138
+ if ( ! inert && push ) {
139
+ if ( parent !== null ) {
140
+ push_effect ( effect , parent ) ;
142
141
}
143
142
144
143
// if we're in a derived, add the effect there too
@@ -391,7 +390,14 @@ export function destroy_effect_children(signal, remove_dom = false) {
391
390
392
391
while ( effect !== null ) {
393
392
var next = effect . next ;
394
- destroy_effect ( effect , remove_dom ) ;
393
+
394
+ if ( ( effect . f & ROOT_EFFECT ) !== 0 ) {
395
+ // this is now an independent root
396
+ effect . parent = null ;
397
+ } else {
398
+ destroy_effect ( effect , remove_dom ) ;
399
+ }
400
+
395
401
effect = next ;
396
402
}
397
403
}
0 commit comments