* @param {number | false} key * @param {null | ((anchor: Node) => void)} fn
(key, fn)
| 34 | * @param {null | ((anchor: Node) => void)} fn |
| 35 | */ |
| 36 | function update_branch(key, fn) { |
| 37 | if (hydrating) { |
| 38 | var data = read_hydration_instruction(/** @type {TemplateNode} */ (marker)); |
| 39 | |
| 40 | // "[n" = branch n, "[-1" = else |
| 41 | if (key !== parseInt(data.substring(1))) { |
| 42 | // Hydration mismatch: remove everything inside the anchor and start fresh. |
| 43 | // This could happen with `{#if browser}...{/if}`, for example |
| 44 | var anchor = skip_nodes(); |
| 45 | |
| 46 | set_hydrate_node(anchor); |
| 47 | branches.anchor = anchor; |
| 48 | |
| 49 | set_hydrating(false); |
| 50 | branches.ensure(key, fn); |
| 51 | set_hydrating(true); |
| 52 | |
| 53 | return; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | branches.ensure(key, fn); |
| 58 | } |
| 59 | |
| 60 | block(() => { |
| 61 | var has_branch = false; |
no test coverage detected