@@ -24,12 +24,6 @@ import {
24
24
export function if_block ( anchor , get_condition , consequent_fn , alternate_fn , elseif = false ) {
25
25
hydrate_block_anchor ( anchor ) ;
26
26
27
- /** @type {undefined | import('#client').Dom } */
28
- let consequent_dom ;
29
-
30
- /** @type {undefined | import('#client').Dom } */
31
- let alternate_dom ;
32
-
33
27
/** @type {import('#client').Effect | null } */
34
28
let consequent_effect = null ;
35
29
@@ -68,48 +62,24 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els
68
62
if ( consequent_effect ) {
69
63
resume_effect ( consequent_effect ) ;
70
64
} else {
71
- consequent_effect = render_effect ( ( ) => {
72
- consequent_dom = consequent_fn ( anchor ) ;
73
-
74
- return ( ) => {
75
- // TODO make this unnecessary by linking the dom to the effect,
76
- // and removing automatically on teardown
77
- if ( consequent_dom !== undefined ) {
78
- remove ( consequent_dom ) ;
79
- consequent_dom = undefined ;
80
- }
81
- } ;
82
- } , true ) ;
65
+ consequent_effect = render_effect ( ( ) => consequent_fn ( anchor ) , true ) ;
83
66
}
84
67
85
68
if ( alternate_effect ) {
86
69
pause_effect ( alternate_effect , ( ) => {
87
70
alternate_effect = null ;
88
- if ( alternate_dom ) remove ( alternate_dom ) ;
89
71
} ) ;
90
72
}
91
73
} else {
92
74
if ( alternate_effect ) {
93
75
resume_effect ( alternate_effect ) ;
94
76
} else if ( alternate_fn ) {
95
- alternate_effect = render_effect ( ( ) => {
96
- alternate_dom = alternate_fn ( anchor ) ;
97
-
98
- return ( ) => {
99
- // TODO make this unnecessary by linking the dom to the effect,
100
- // and removing automatically on teardown
101
- if ( alternate_dom !== undefined ) {
102
- remove ( alternate_dom ) ;
103
- alternate_dom = undefined ;
104
- }
105
- } ;
106
- } , true ) ;
77
+ alternate_effect = render_effect ( ( ) => alternate_fn ( anchor ) , true ) ;
107
78
}
108
79
109
80
if ( consequent_effect ) {
110
81
pause_effect ( consequent_effect , ( ) => {
111
82
consequent_effect = null ;
112
- if ( consequent_dom ) remove ( consequent_dom ) ;
113
83
} ) ;
114
84
}
115
85
}
@@ -125,16 +95,7 @@ export function if_block(anchor, get_condition, consequent_fn, alternate_fn, els
125
95
}
126
96
127
97
if_effect . ondestroy = ( ) => {
128
- // TODO make this unnecessary by linking the dom to the effect,
129
- // and removing automatically on teardown
130
- if ( consequent_dom !== undefined ) {
131
- remove ( consequent_dom ) ;
132
- }
133
-
134
- if ( alternate_dom !== undefined ) {
135
- remove ( alternate_dom ) ;
136
- }
137
-
98
+ // TODO why is this not automatic? this should be children of `if_effect`
138
99
if ( consequent_effect ) {
139
100
destroy_effect ( consequent_effect ) ;
140
101
}
0 commit comments