@@ -4,7 +4,7 @@ import { EFFECT_TRANSPARENT } from '#client/constants';
4
4
import { block , branch , pause_effect } from '../../reactivity/effects.js' ;
5
5
import { current_batch } from '../../reactivity/batch.js' ;
6
6
import { hydrate_next , hydrate_node , hydrating } from '../hydration.js' ;
7
- import { create_text , should_defer_append } from '../operations.js' ;
7
+ import { should_defer_append } from '../operations.js' ;
8
8
9
9
/**
10
10
* @template P
@@ -27,19 +27,13 @@ export function component(node, get_component, render_fn) {
27
27
/** @type {Effect | null } */
28
28
var effect ;
29
29
30
- /** @type {DocumentFragment | null } */
31
- var offscreen_fragment = null ;
32
-
33
30
/** @type {Effect | null } */
34
31
var pending_effect = null ;
35
32
36
33
function commit ( ) {
37
- if ( offscreen_fragment ) {
38
- // remove the anchor
39
- /** @type {Text } */ ( offscreen_fragment . lastChild ) . remove ( ) ;
40
-
41
- anchor . before ( offscreen_fragment ) ;
42
- offscreen_fragment = null ;
34
+ if ( effect ) {
35
+ pause_effect ( effect ) ;
36
+ effect = null ;
43
37
}
44
38
45
39
effect = pending_effect ;
@@ -51,25 +45,23 @@ export function component(node, get_component, render_fn) {
51
45
52
46
var defer = should_defer_append ( ) ;
53
47
54
- if ( effect ) {
55
- pause_effect ( effect ) ;
56
- effect = null ;
57
- }
58
-
59
48
if ( component ) {
60
- var target = anchor ;
61
-
62
49
if ( defer ) {
63
- offscreen_fragment = document . createDocumentFragment ( ) ;
64
- offscreen_fragment . append ( ( target = create_text ( ) ) ) ;
65
50
if ( effect ) {
66
51
/** @type {Batch } */ ( current_batch ) . skipped_effects . add ( effect ) ;
67
52
}
53
+ /** @type {Batch } */ ( current_batch ) . add_callback ( ( ) => {
54
+ if ( effect ) {
55
+ pause_effect ( effect ) ;
56
+ effect = null ;
57
+ }
58
+ effect = branch ( ( ) => render_fn ( anchor , component ) ) ;
59
+ } ) ;
60
+ } else {
61
+ pending_effect = branch ( ( ) => render_fn ( anchor , component ) ) ;
62
+ commit ( ) ;
68
63
}
69
- pending_effect = branch ( ( ) => render_fn ( target , component ) ) ;
70
- }
71
-
72
- if ( defer ) {
64
+ } else if ( defer ) {
73
65
/** @type {Batch } */ ( current_batch ) . add_callback ( commit ) ;
74
66
} else {
75
67
commit ( ) ;
0 commit comments