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 {
boundary.update_pending_count(-1);
batch.decrement(blocking);
}
if (was_hydrating) {
set_hydrating(false);
set_hydrate_node(undefined);
}
}
});
}

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

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

Loading…
Cancel
Save