@@ -76,19 +76,12 @@ export function boundary(node, props, boundary_fn) {
7676 var async_fragment = null ;
7777 var async_count = 0 ;
7878
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-
8679 block ( ( ) => {
8780 var boundary = /** @type {Effect } */ ( active_effect ) ;
8881 var hydrate_open = hydrate_node ;
8982 var is_creating_fallback = false ;
9083
91- const render_snippet = ( /** @type { () => void } */ snippet_fn ) => {
84+ var render_snippet = ( /** @type { () => void } */ snippet_fn ) => {
9285 with_boundary ( boundary , ( ) => {
9386 is_creating_fallback = true ;
9487
@@ -107,18 +100,9 @@ export function boundary(node, props, boundary_fn) {
107100
108101 // @ts -ignore We re-use the effect's fn property to avoid allocation of an additional field
109102 boundary . fn = ( /** @type {unknown } */ input ) => {
110- let pending = props . pending ;
103+ let pending = /** @type { (anchor: Node) => void } */ ( props . pending ) ;
111104
112105 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-
122106 if ( async_count ++ === 0 ) {
123107 queue_boundary_micro_task ( ( ) => {
124108 if ( async_effect || ! boundary_effect ) {
@@ -159,15 +143,6 @@ export function boundary(node, props, boundary_fn) {
159143 }
160144
161145 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-
171146 if ( -- async_count === 0 ) {
172147 queue_boundary_micro_task ( ( ) => {
173148 if ( ! async_effect ) {
@@ -229,6 +204,11 @@ export function boundary(node, props, boundary_fn) {
229204 }
230205 } ;
231206
207+ if ( props . pending ) {
208+ // @ts -ignore
209+ boundary . fn . pending = true ;
210+ }
211+
232212 if ( hydrating ) {
233213 hydrate_next ( ) ;
234214 }
@@ -285,11 +265,19 @@ export function capture() {
285265 } ;
286266}
287267
268+ /**
269+ * @param {Effect } boundary
270+ */
271+ export function is_pending_boundary ( boundary ) {
272+ // @ts -ignore
273+ return boundary . fn . pending ;
274+ }
275+
288276export function suspend ( ) {
289277 var boundary = active_effect ;
290278
291279 while ( boundary !== null ) {
292- if ( ( boundary . f & BOUNDARY_EFFECT ) !== 0 ) {
280+ if ( ( boundary . f & BOUNDARY_EFFECT ) !== 0 && is_pending_boundary ( boundary ) ) {
293281 break ;
294282 }
295283
0 commit comments