@@ -76,19 +76,12 @@ export function boundary(node, props, boundary_fn) {
76
76
var async_fragment = null ;
77
77
var async_count = 0 ;
78
78
79
- /** @type {Effect | null } */
80
- var parent_boundary = /** @type {Effect } */ ( active_effect ) . parent ;
81
-
82
- while ( parent_boundary !== null && ( parent_boundary . f & BOUNDARY_EFFECT ) === 0 ) {
83
- parent_boundary = parent_boundary . parent ;
84
- }
85
-
86
79
block ( ( ) => {
87
80
var boundary = /** @type {Effect } */ ( active_effect ) ;
88
81
var hydrate_open = hydrate_node ;
89
82
var is_creating_fallback = false ;
90
83
91
- const render_snippet = ( /** @type { () => void } */ snippet_fn ) => {
84
+ var render_snippet = ( /** @type { () => void } */ snippet_fn ) => {
92
85
with_boundary ( boundary , ( ) => {
93
86
is_creating_fallback = true ;
94
87
@@ -107,18 +100,9 @@ export function boundary(node, props, boundary_fn) {
107
100
108
101
// @ts -ignore We re-use the effect's fn property to avoid allocation of an additional field
109
102
boundary . fn = ( /** @type {unknown } */ input ) => {
110
- let pending = props . pending ;
103
+ let pending = /** @type { (anchor: Node) => void } */ ( props . pending ) ;
111
104
112
105
if ( input === ASYNC_INCREMENT ) {
113
- if ( ! pending ) {
114
- if ( ! parent_boundary ) {
115
- e . await_outside_boundary ( ) ;
116
- }
117
-
118
- // @ts -ignore
119
- return parent_boundary . fn ( input ) ;
120
- }
121
-
122
106
if ( async_count ++ === 0 ) {
123
107
queue_boundary_micro_task ( ( ) => {
124
108
if ( async_effect || ! boundary_effect ) {
@@ -159,15 +143,6 @@ export function boundary(node, props, boundary_fn) {
159
143
}
160
144
161
145
if ( input === ASYNC_DECREMENT ) {
162
- if ( ! pending ) {
163
- if ( ! parent_boundary ) {
164
- e . await_outside_boundary ( ) ;
165
- }
166
-
167
- // @ts -ignore
168
- return parent_boundary . fn ( input ) ;
169
- }
170
-
171
146
if ( -- async_count === 0 ) {
172
147
queue_boundary_micro_task ( ( ) => {
173
148
if ( ! async_effect ) {
@@ -229,6 +204,11 @@ export function boundary(node, props, boundary_fn) {
229
204
}
230
205
} ;
231
206
207
+ if ( props . pending ) {
208
+ // @ts -ignore
209
+ boundary . fn . pending = true ;
210
+ }
211
+
232
212
if ( hydrating ) {
233
213
hydrate_next ( ) ;
234
214
}
@@ -285,11 +265,19 @@ export function capture() {
285
265
} ;
286
266
}
287
267
268
+ /**
269
+ * @param {Effect } boundary
270
+ */
271
+ export function is_pending_boundary ( boundary ) {
272
+ // @ts -ignore
273
+ return boundary . fn . pending ;
274
+ }
275
+
288
276
export function suspend ( ) {
289
277
var boundary = active_effect ;
290
278
291
279
while ( boundary !== null ) {
292
- if ( ( boundary . f & BOUNDARY_EFFECT ) !== 0 ) {
280
+ if ( ( boundary . f & BOUNDARY_EFFECT ) !== 0 && is_pending_boundary ( boundary ) ) {
293
281
break ;
294
282
}
295
283
0 commit comments