simplify/fix hydration restoration

pull/17038/head
Rich Harris 4 weeks ago
parent d029d9f9bb
commit a8708cacfa

@ -50,10 +50,11 @@ export function async(node, blockers = [], expressions = [], fn) {
} finally { } finally {
boundary.update_pending_count(-1); boundary.update_pending_count(-1);
batch.decrement(blocking); batch.decrement(blocking);
}
if (was_hydrating) { if (was_hydrating) {
set_hydrating(false); set_hydrating(false);
set_hydrate_node(undefined);
}
} }
}); });
} }

@ -6,7 +6,8 @@ import {
read_hydration_instruction, read_hydration_instruction,
skip_nodes, skip_nodes,
set_hydrate_node, set_hydrate_node,
set_hydrating set_hydrating,
hydrate_node
} from '../hydration.js'; } from '../hydration.js';
import { block } from '../../reactivity/effects.js'; import { block } from '../../reactivity/effects.js';
import { HYDRATION_START_ELSE } from '../../../../constants.js'; import { HYDRATION_START_ELSE } from '../../../../constants.js';

@ -53,8 +53,6 @@ export function flatten(blockers, sync, async, fn) {
var restore = capture(); var restore = capture();
var was_hydrating = hydrating;
function run() { function run() {
Promise.all(async.map((expression) => async_derived(expression))) Promise.all(async.map((expression) => async_derived(expression)))
.then((result) => { .then((result) => {
@ -69,10 +67,6 @@ export function flatten(blockers, sync, async, fn) {
} }
} }
if (was_hydrating) {
set_hydrating(false);
}
batch?.deactivate(); batch?.deactivate();
unset_context(); unset_context();
}) })
@ -108,12 +102,6 @@ export function capture() {
var previous_component_context = component_context; var previous_component_context = component_context;
var previous_batch = current_batch; var previous_batch = current_batch;
var was_hydrating = hydrating;
if (was_hydrating) {
var previous_hydrate_node = hydrate_node;
}
if (DEV) { if (DEV) {
var previous_dev_stack = dev_stack; var previous_dev_stack = dev_stack;
} }
@ -124,11 +112,6 @@ export function capture() {
set_component_context(previous_component_context); set_component_context(previous_component_context);
if (activate_batch) previous_batch?.activate(); if (activate_batch) previous_batch?.activate();
if (was_hydrating) {
set_hydrating(true);
set_hydrate_node(previous_hydrate_node);
}
if (DEV) { if (DEV) {
set_from_async_derived(null); set_from_async_derived(null);
set_dev_stack(previous_dev_stack); set_dev_stack(previous_dev_stack);
@ -265,10 +248,6 @@ export async function async_body(anchor, fn) {
invoke_error_boundary(error, active); invoke_error_boundary(error, active);
} }
} finally { } finally {
if (was_hydrating) {
set_hydrating(false);
}
boundary.update_pending_count(-1); boundary.update_pending_count(-1);
batch.decrement(blocking); batch.decrement(blocking);
@ -294,8 +273,6 @@ export function run(thunks) {
/** @type {null | { error: any }} */ /** @type {null | { error: any }} */
var errored = null; var errored = null;
let was_hydrating = hydrating;
/** @param {any} error */ /** @param {any} error */
const handle_error = (error) => { const handle_error = (error) => {
errored = { error }; // wrap in object in case a promise rejects with a falsy value errored = { error }; // wrap in object in case a promise rejects with a falsy value
@ -326,19 +303,11 @@ export function run(thunks) {
} finally { } finally {
// TODO do we need it here as well as below? // TODO do we need it here as well as below?
unset_context(); unset_context();
if (was_hydrating) {
set_hydrating(false);
}
} }
}) })
.catch(handle_error) .catch(handle_error)
.finally(() => { .finally(() => {
unset_context(); unset_context();
if (was_hydrating) {
set_hydrating(false);
}
}); });
promises.push(promise); promises.push(promise);

@ -256,4 +256,4 @@ export function transition_slide_display(value) {
} else { } else {
console.warn(`https://svelte.dev/e/transition_slide_display`); console.warn(`https://svelte.dev/e/transition_slide_display`);
} }
} }

Loading…
Cancel
Save