pull/12335/head
Rich Harris 2 years ago
parent 840c572fb8
commit 10f02f44ba

@ -113,11 +113,7 @@ const bundle = await bundle_code(
).js.code
);
if (
!bundle.includes('hydrating') &&
!bundle.includes('hydrate_node') &&
!bundle.includes('hydrate_next')
) {
if (!bundle.includes('hydrate_node') && !bundle.includes('hydrate_next')) {
// eslint-disable-next-line no-console
console.error(`✅ Hydration code treeshakeable`);
} else {

@ -2184,7 +2184,7 @@ export const template_visitors = {
);
// TODO only do this when necessary, and use a function with `if (hydrating)` so that it noops for non-hydraters
child_state.init.push(b.stmt(b.call('$.set_hydrate_node', context.state.node)));
child_state.init.push(b.stmt(b.call('$.reset', context.state.node)));
if (has_declaration) {
context.state.init.push(

@ -1,4 +1,3 @@
import { hydrating, set_hydrate_nodes } from '../hydration.js';
import { render_effect } from '../../reactivity/effects.js';
/**
@ -7,12 +6,6 @@ import { render_effect } from '../../reactivity/effects.js';
* @returns {void}
*/
export function css_props(element, get_styles) {
if (hydrating) {
set_hydrate_nodes(
/** @type {import('#client').TemplateNode[]} */ ([...element.childNodes]).slice(0, -1)
);
}
render_effect(() => {
render_effect(() => {
var styles = get_styles();

@ -1,5 +1,5 @@
import { namespace_svg } from '../../../../constants.js';
import { hydrating, set_hydrate_node, set_hydrate_nodes } from '../hydration.js';
import { hydrating, set_hydrate_node } from '../hydration.js';
import { empty } from '../operations.js';
import {
block,

@ -23,3 +23,10 @@ export function hydrate_next() {
hydrate_node = /** @type {TemplateNode} */ (hydrate_node.nextSibling);
return hydrate_node;
}
/** @param {TemplateNode} node */
export function reset(node) {
if (hydrating) {
hydrate_node = node;
}
}

@ -1,5 +1,5 @@
/** @import { Effect, EffectNodes, TemplateNode } from '#client' */
import { get_start, hydrate_next, hydrate_node, hydrating, set_hydrate_node } from './hydration.js';
import { hydrate_next, hydrate_node, hydrating, set_hydrate_node } from './hydration.js';
import { empty } from './operations.js';
import { create_fragment_from_html } from './reconciler.js';
import { current_effect } from '../runtime.js';

@ -62,7 +62,7 @@ export {
bind_focused
} from './dom/elements/bindings/universal.js';
export { bind_window_scroll, bind_window_size } from './dom/elements/bindings/window.js';
export { set_hydrate_node } from './dom/hydration.js';
export { reset } from './dom/hydration.js';
export {
once,
preventDefault,

Loading…
Cancel
Save