pull/12215/head
Rich Harris 2 months ago
parent ea0acceb3f
commit 1a14f8c0b9

@ -1930,7 +1930,7 @@ export const template_visitors = {
}
if (node.name === 'noscript') {
context.state.template.push('<!>');
context.state.template.push('<noscript></noscript>');
return;
}
if (node.name === 'script') {

@ -18,7 +18,7 @@ export function hmr(source) {
/** @type {import("#client").Effect} */
let effect;
block(() => {
block(anchor, 0, () => {
const component = get(source);
if (effect) {

@ -105,7 +105,7 @@ export function await_block(anchor, get_input, pending_fn, then_fn, catch_fn) {
}
}
var effect = block(() => {
var effect = block(anchor, 0, () => {
if (input === (input = get_input())) return;
if (is_promise(input)) {

@ -122,7 +122,7 @@ export function each(anchor, flags, get_collection, get_key, render_fn, fallback
/** @type {import('#client').Effect | null} */
var fallback = null;
block(() => {
block(anchor, 0, () => {
var collection = get_collection();
var array = is_array(collection)

@ -31,9 +31,7 @@ export function if_block(
var flags = elseif ? EFFECT_TRANSPARENT : 0;
block(() => {
assign_nodes(null, anchor); // TODO `block(anchor, () => {...})`
block(anchor, flags, () => {
if (condition === (condition = !!get_condition())) return;
/** Whether or not there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */
@ -81,5 +79,5 @@ export function if_block(
// continue in hydration mode
set_hydrating(true);
}
}, flags);
});
}

@ -16,7 +16,7 @@ export function key_block(anchor, get_key, render_fn) {
/** @type {import('#client').Effect} */
let effect;
block(() => {
block(anchor, 0, () => {
if (safe_not_equal(key, (key = get_key()))) {
if (effect) {
pause_effect(effect);

@ -21,7 +21,7 @@ export function snippet(get_snippet, node, ...args) {
/** @type {import('#client').Effect | null} */
var snippet_effect;
block(() => {
block(null, EFFECT_TRANSPARENT, () => {
if (snippet === (snippet = get_snippet())) return;
if (snippet_effect) {
@ -32,7 +32,7 @@ export function snippet(get_snippet, node, ...args) {
if (snippet) {
snippet_effect = branch(() => /** @type {SnippetFn} */ (snippet)(node, ...args));
}
}, EFFECT_TRANSPARENT);
});
}
/**

@ -16,7 +16,7 @@ export function component(get_component, render_fn) {
/** @type {import('#client').Effect | null} */
let effect;
block(() => {
block(null, 0, () => {
if (component === (component = get_component())) return;
if (effect) {

@ -48,8 +48,7 @@ export function element(node, get_tag, is_svg, render_fn, get_namespace, locatio
*/
let each_item_block = current_each_item;
block(() => {
const element_effect = /** @type {import('#client').Effect} */ (current_effect);
block(anchor, 0, () => {
const next_tag = get_tag() || null;
const ns = get_namespace
? get_namespace()

@ -47,7 +47,7 @@ export function head(render_fn) {
}
try {
block(() => render_fn(anchor));
block(null, 0, () => render_fn(anchor));
} finally {
if (was_hydrating) {
set_hydrate_nodes(/** @type {import('#client').TemplateNode[]} */ (previous_hydrate_nodes));

@ -299,11 +299,14 @@ export function template_effect(fn) {
}
/**
* @param {(() => void)} fn
* @param {import('#client').TemplateNode | null} anchor
* @param {number} flags
* @param {(() => void)} fn
*/
export function block(fn, flags = 0) {
return create_effect(RENDER_EFFECT | BLOCK_EFFECT | flags, fn, true);
export function block(anchor, flags, fn) {
const effect = create_effect(RENDER_EFFECT | BLOCK_EFFECT | flags, fn, true);
if (anchor !== null) effect.nodes = { start: null, end: anchor };
return effect;
}
/** @param {(() => void)} fn */

Loading…
Cancel
Save