@@ -28,53 +28,56 @@ export function if_block(
28
28
/** @type {boolean | null } */
29
29
let condition = null ;
30
30
31
- block ( ( ) => {
32
- if ( condition === ( condition = ! ! get_condition ( ) ) ) return ;
31
+ block (
32
+ ( ) => {
33
+ if ( condition === ( condition = ! ! get_condition ( ) ) ) return ;
33
34
34
- /** Whether or not there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */
35
- let mismatch = false ;
35
+ /** Whether or not there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */
36
+ let mismatch = false ;
36
37
37
- if ( hydrating ) {
38
- const is_else = anchor . data === HYDRATION_END_ELSE ;
38
+ if ( hydrating ) {
39
+ const is_else = anchor . data === HYDRATION_END_ELSE ;
39
40
40
- if ( condition === is_else ) {
41
- // Hydration mismatch: remove everything inside the anchor and start fresh.
42
- // This could happen with `{#if browser}...{/if}`, for example
43
- remove ( hydrate_nodes ) ;
44
- set_hydrating ( false ) ;
45
- mismatch = true ;
41
+ if ( condition === is_else ) {
42
+ // Hydration mismatch: remove everything inside the anchor and start fresh.
43
+ // This could happen with `{#if browser}...{/if}`, for example
44
+ remove ( hydrate_nodes ) ;
45
+ set_hydrating ( false ) ;
46
+ mismatch = true ;
47
+ }
46
48
}
47
- }
48
49
49
- if ( condition ) {
50
- if ( consequent_effect ) {
51
- resume_effect ( consequent_effect ) ;
50
+ if ( condition ) {
51
+ if ( consequent_effect ) {
52
+ resume_effect ( consequent_effect ) ;
53
+ } else {
54
+ consequent_effect = branch ( ( ) => consequent_fn ( anchor ) ) ;
55
+ }
56
+
57
+ if ( alternate_effect ) {
58
+ pause_effect ( alternate_effect , ( ) => {
59
+ alternate_effect = null ;
60
+ } ) ;
61
+ }
52
62
} else {
53
- consequent_effect = branch ( ( ) => consequent_fn ( anchor ) ) ;
54
- }
63
+ if ( alternate_effect ) {
64
+ resume_effect ( alternate_effect ) ;
65
+ } else if ( alternate_fn ) {
66
+ alternate_effect = branch ( ( ) => alternate_fn ( anchor ) ) ;
67
+ }
55
68
56
- if ( alternate_effect ) {
57
- pause_effect ( alternate_effect , ( ) => {
58
- alternate_effect = null ;
59
- } ) ;
60
- }
61
- } else {
62
- if ( alternate_effect ) {
63
- resume_effect ( alternate_effect ) ;
64
- } else if ( alternate_fn ) {
65
- alternate_effect = branch ( ( ) => alternate_fn ( anchor ) ) ;
69
+ if ( consequent_effect ) {
70
+ pause_effect ( consequent_effect , ( ) => {
71
+ consequent_effect = null ;
72
+ } ) ;
73
+ }
66
74
}
67
75
68
- if ( consequent_effect ) {
69
- pause_effect ( consequent_effect , ( ) => {
70
- consequent_effect = null ;
71
- } ) ;
76
+ if ( mismatch ) {
77
+ // continue in hydration mode
78
+ set_hydrating ( true ) ;
72
79
}
73
- }
74
-
75
- if ( mismatch ) {
76
- // continue in hydration mode
77
- set_hydrating ( true ) ;
78
- }
79
- } , EFFECT_TRANSPARENT ) ;
80
+ } ,
81
+ elseif ? EFFECT_TRANSPARENT : 0
82
+ ) ;
80
83
}
0 commit comments