@@ -13,12 +13,11 @@ import { HYDRATION_START, HYDRATION_START_ELSE, UNINITIALIZED } from '../../../.
1313
1414/**
1515 * @param {TemplateNode } node
16- * @param {(branch: (fn: (anchor: Node, r_index?: number, h_index?: number) => void, flag?: boolean) => void) => void } fn
17- * @param {number } [root_index]
18- * @param {number } [hydrate_index]
16+ * @param {(branch: (fn: (anchor: Node, elseif?: [number,number]) => void, flag?: boolean) => void) => void } fn
17+ * @param {[number,number] } [elseif]
1918 * @returns {void }
2019 */
21- export function if_block ( node , fn , root_index = 0 , hydrate_index ) {
20+ export function if_block ( node , fn , [ root_index , hydrate_index ] = [ 0 , 0 ] ) {
2221 if ( hydrating && root_index === 0 ) {
2322 hydrate_next ( ) ;
2423 }
@@ -39,7 +38,7 @@ export function if_block(node, fn, root_index = 0, hydrate_index) {
3938 var has_branch = false ;
4039
4140 const set_branch = (
42- /** @type {(anchor: Node, r_index ?: number, h_index?: number) => void } */ fn ,
41+ /** @type {(anchor: Node, elseif ?: [ number,number] ) => void } */ fn ,
4342 flag = true
4443 ) => {
4544 has_branch = true ;
@@ -48,15 +47,15 @@ export function if_block(node, fn, root_index = 0, hydrate_index) {
4847
4948 const update_branch = (
5049 /** @type {boolean | null } */ new_condition ,
51- /** @type {null | ((anchor: Node, r_index ?: number, h_index?: number) => void) } */ fn
50+ /** @type {null | ((anchor: Node, elseif ?: [ number,number] ) => void) } */ fn
5251 ) => {
5352 if ( condition === ( condition = new_condition ) ) return ;
5453
5554 /** Whether or not there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */
5655 let mismatch = false ;
5756
58- if ( hydrating && hydrate_index != - 1 ) {
59- if ( hydrate_index === undefined ) {
57+ if ( hydrating && hydrate_index !== - 1 ) {
58+ if ( root_index === 0 ) {
6059 const data = /** @type {Comment } */ ( anchor ) . data ;
6160 if ( data === HYDRATION_START ) {
6261 hydrate_index = 0 ;
@@ -96,7 +95,7 @@ export function if_block(node, fn, root_index = 0, hydrate_index) {
9695 if ( alternate_effect ) {
9796 resume_effect ( alternate_effect ) ;
9897 } else if ( fn ) {
99- alternate_effect = branch ( ( ) => fn ( anchor , root_index + 1 , hydrate_index ) ) ;
98+ alternate_effect = branch ( ( ) => fn ( anchor , [ root_index + 1 , hydrate_index ] ) ) ;
10099 }
101100
102101 if ( consequent_effect ) {
0 commit comments