fix head stuff

pull/12215/head
Rich Harris 2 months ago
parent af05454d5d
commit 520b3e16bf

@ -17,6 +17,7 @@ export const EFFECT_TRANSPARENT = 1 << 15;
/** Svelte 4 legacy mode props need to be handled with deriveds and be recognized elsewhere, hence the dedicated flag */
export const LEGACY_DERIVED_PROP = 1 << 16;
export const INSPECT_EFFECT = 1 << 17;
export const HEAD_EFFECT = 1 << 18;
export const STATE_SYMBOL = Symbol('$state');
export const STATE_FROZEN_SYMBOL = Symbol('$state.frozen');

@ -2,6 +2,7 @@ import { hydrate_anchor, hydrate_nodes, hydrating, set_hydrate_nodes } from '../
import { empty } from '../operations.js';
import { block } from '../../reactivity/effects.js';
import { HYDRATION_END, HYDRATION_START } from '../../../../constants.js';
import { HEAD_EFFECT } from '../../constants.js';
/**
* @type {Node | undefined}
@ -47,7 +48,7 @@ export function head(render_fn) {
}
try {
block(null, 0, () => render_fn(anchor));
block(null, HEAD_EFFECT, () => render_fn(anchor));
} finally {
if (was_hydrating) {
set_hydrate_nodes(/** @type {import('#client').TemplateNode[]} */ (previous_hydrate_nodes));

@ -31,7 +31,8 @@ import {
DERIVED,
UNOWNED,
CLEAN,
INSPECT_EFFECT
INSPECT_EFFECT,
HEAD_EFFECT
} from '../constants.js';
import { set } from './sources.js';
import { remove } from '../dom/reconciler.js';
@ -341,7 +342,7 @@ export function execute_effect_teardown(effect) {
export function destroy_effect(effect, remove_dom = true) {
var removed = false;
if (remove_dom) {
if (remove_dom || (effect.f & HEAD_EFFECT) !== 0) {
var start = get_first_node(effect);
var end = get_last_node(effect);
@ -391,7 +392,10 @@ export function get_first_node(effect) {
}
var child = effect.first;
while (child && (child.f & (BLOCK_EFFECT | BRANCH_EFFECT)) === 0) {
while (
child &&
((child.f & (BLOCK_EFFECT | BRANCH_EFFECT)) === 0 || (child.f & HEAD_EFFECT) !== 0)
) {
child = child.next;
}

Loading…
Cancel
Save