@@ -70,7 +70,7 @@ import {
70
70
} from './hydration.js' ;
71
71
import { array_from , define_property , get_descriptor , get_descriptors , is_array } from './utils.js' ;
72
72
import { is_promise } from '../common.js' ;
73
- import { bind_transition , remove_in_transitions , trigger_transitions } from './transitions.js' ;
73
+ import { bind_transition , trigger_transitions } from './transitions.js' ;
74
74
75
75
/** @type {Set<string> } */
76
76
const all_registerd_events = new Set ( ) ;
@@ -1355,8 +1355,6 @@ export function slot(anchor_node, slot_fn, slot_props, fallback_fn) {
1355
1355
function if_block ( anchor_node , condition_fn , consequent_fn , alternate_fn ) {
1356
1356
const block = create_if_block ( ) ;
1357
1357
hydrate_block_anchor ( anchor_node ) ;
1358
- const consequent_transitions = new Set ( ) ;
1359
- const alternate_transitions = new Set ( ) ;
1360
1358
const previous_hydration_fragment = current_hydration_fragment ;
1361
1359
1362
1360
/** @type {null | import('./types.js').TemplateNode | Array<import('./types.js').TemplateNode> } */
@@ -1366,59 +1364,32 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
1366
1364
let has_mounted = false ;
1367
1365
let has_mounted_branch = false ;
1368
1366
1369
- block . r =
1370
- /**
1371
- * @param {import('./types.js').Transition } transition
1372
- * @returns {void }
1373
- */
1374
- ( transition ) => {
1375
- // block.current
1376
- if ( block . c ) {
1377
- consequent_transitions . add ( transition ) ;
1378
- transition . f ( ( ) => {
1379
- consequent_transitions . delete ( transition ) ;
1380
- remove_in_transitions ( consequent_transitions ) ;
1381
- if ( consequent_transitions . size === 0 ) {
1382
- execute_effect ( consequent_effect ) ;
1383
- }
1384
- } ) ;
1385
- } else {
1386
- alternate_transitions . add ( transition ) ;
1387
- transition . f ( ( ) => {
1388
- alternate_transitions . delete ( transition ) ;
1389
- remove_in_transitions ( alternate_transitions ) ;
1390
- if ( alternate_transitions . size === 0 ) {
1391
- execute_effect ( alternate_effect ) ;
1392
- }
1393
- } ) ;
1394
- }
1395
- } ;
1396
1367
const if_effect = render_effect (
1397
1368
( ) => {
1398
1369
const result = ! ! condition_fn ( ) ;
1399
- if ( block . c !== result || ! has_mounted ) {
1400
- block . c = result ;
1370
+ if ( block . v !== result || ! has_mounted ) {
1371
+ block . v = result ;
1401
1372
if ( has_mounted ) {
1373
+ const consequent_transitions = block . c ;
1374
+ const alternate_transitions = block . a ;
1402
1375
if ( result ) {
1403
- remove_in_transitions ( alternate_transitions ) ;
1404
- if ( alternate_transitions . size === 0 ) {
1376
+ if ( alternate_transitions === null || alternate_transitions . size === 0 ) {
1405
1377
execute_effect ( alternate_effect ) ;
1406
1378
} else {
1407
1379
trigger_transitions ( alternate_transitions , 'out' ) ;
1408
1380
}
1409
- if ( consequent_transitions . size === 0 ) {
1381
+ if ( consequent_transitions === null || consequent_transitions . size === 0 ) {
1410
1382
execute_effect ( consequent_effect ) ;
1411
1383
} else {
1412
1384
trigger_transitions ( consequent_transitions , 'in' ) ;
1413
1385
}
1414
1386
} else {
1415
- remove_in_transitions ( consequent_transitions ) ;
1416
- if ( consequent_transitions . size === 0 ) {
1387
+ if ( consequent_transitions === null || consequent_transitions . size === 0 ) {
1417
1388
execute_effect ( consequent_effect ) ;
1418
1389
} else {
1419
1390
trigger_transitions ( consequent_transitions , 'out' ) ;
1420
1391
}
1421
- if ( alternate_transitions . size === 0 ) {
1392
+ if ( alternate_transitions === null || alternate_transitions . size === 0 ) {
1422
1393
execute_effect ( alternate_effect ) ;
1423
1394
} else {
1424
1395
trigger_transitions ( alternate_transitions , 'in' ) ;
@@ -1455,7 +1426,7 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
1455
1426
remove ( consequent_dom ) ;
1456
1427
consequent_dom = null ;
1457
1428
}
1458
- if ( block . c ) {
1429
+ if ( block . v ) {
1459
1430
consequent_fn ( anchor_node ) ;
1460
1431
if ( ! has_mounted_branch ) {
1461
1432
// Restore previous fragment so that Svelte continues to operate in hydration mode
@@ -1469,14 +1440,15 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
1469
1440
block ,
1470
1441
true
1471
1442
) ;
1443
+ block . ce = consequent_effect ;
1472
1444
// Managed effect
1473
1445
const alternate_effect = render_effect (
1474
1446
( ) => {
1475
1447
if ( alternate_dom !== null ) {
1476
1448
remove ( alternate_dom ) ;
1477
1449
alternate_dom = null ;
1478
1450
}
1479
- if ( ! block . c ) {
1451
+ if ( ! block . v ) {
1480
1452
if ( alternate_fn !== null ) {
1481
1453
alternate_fn ( anchor_node ) ;
1482
1454
}
@@ -1492,6 +1464,7 @@ function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn) {
1492
1464
block ,
1493
1465
true
1494
1466
) ;
1467
+ block . ae = alternate_effect ;
1495
1468
push_destroy_fn ( if_effect , ( ) => {
1496
1469
if ( consequent_dom !== null ) {
1497
1470
remove ( consequent_dom ) ;
@@ -1676,7 +1649,6 @@ export function component(anchor_node, component_fn, render_fn) {
1676
1649
transitions . add ( transition ) ;
1677
1650
transition . f ( ( ) => {
1678
1651
transitions . delete ( transition ) ;
1679
- remove_in_transitions ( transitions ) ;
1680
1652
if ( transitions . size === 0 ) {
1681
1653
if ( render . e !== null ) {
1682
1654
if ( render . d !== null ) {
@@ -1724,7 +1696,6 @@ export function component(anchor_node, component_fn, render_fn) {
1724
1696
return ;
1725
1697
}
1726
1698
const transitions = render . s ;
1727
- remove_in_transitions ( transitions ) ;
1728
1699
if ( transitions . size === 0 ) {
1729
1700
if ( render . d !== null ) {
1730
1701
remove ( render . d ) ;
@@ -1804,7 +1775,6 @@ function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
1804
1775
transitions . add ( transition ) ;
1805
1776
transition . f ( ( ) => {
1806
1777
transitions . delete ( transition ) ;
1807
- remove_in_transitions ( transitions ) ;
1808
1778
if ( transitions . size === 0 ) {
1809
1779
if ( render . e !== null ) {
1810
1780
if ( render . d !== null ) {
@@ -1861,7 +1831,6 @@ function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
1861
1831
return ;
1862
1832
}
1863
1833
const transitions = render . s ;
1864
- remove_in_transitions ( transitions ) ;
1865
1834
if ( transitions . size === 0 ) {
1866
1835
if ( render . d !== null ) {
1867
1836
remove ( render . d ) ;
@@ -1966,7 +1935,6 @@ export function key(anchor_node, key, render_fn) {
1966
1935
transitions . add ( transition ) ;
1967
1936
transition . f ( ( ) => {
1968
1937
transitions . delete ( transition ) ;
1969
- remove_in_transitions ( transitions ) ;
1970
1938
if ( transitions . size === 0 ) {
1971
1939
if ( render . e !== null ) {
1972
1940
if ( render . d !== null ) {
@@ -2007,7 +1975,6 @@ export function key(anchor_node, key, render_fn) {
2007
1975
return ;
2008
1976
}
2009
1977
const transitions = render . s ;
2010
- remove_in_transitions ( transitions ) ;
2011
1978
if ( transitions . size === 0 ) {
2012
1979
if ( render . d !== null ) {
2013
1980
remove ( render . d ) ;
@@ -2195,7 +2162,6 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
2195
2162
transitions . add ( transition ) ;
2196
2163
transition . f ( ( ) => {
2197
2164
transitions . delete ( transition ) ;
2198
- remove_in_transitions ( transitions ) ;
2199
2165
if ( transitions . size === 0 ) {
2200
2166
if ( fallback . e !== null ) {
2201
2167
if ( fallback . d !== null ) {
0 commit comments