pull/12335/head
Rich Harris 2 years ago
parent 86492e5ebd
commit 6b3a3d66e7

@ -1668,11 +1668,7 @@ export const template_visitors = {
state
});
body.push(
b.var(id, b.call('$.text', b.id('$$anchor'))),
...state.before_init,
...state.init
);
body.push(b.var(id, b.call('$.text')), ...state.before_init, ...state.init);
close = b.stmt(b.call('$.append', b.id('$$anchor'), id));
} else {
if (is_standalone) {

@ -1143,7 +1143,7 @@ const template_visitors = {
},
HtmlTag(node, context) {
const expression = /** @type {import('estree').Expression} */ (context.visit(node.expression));
context.state.template.push(block_open, expression, block_close);
context.state.template.push(block_open, expression, b.literal('<!--/html-->'));
},
ConstTag(node, { state, visit }) {
const declaration = node.declaration.declarations[0];

@ -1,5 +1,6 @@
/** @import { Effect, TemplateNode } from '#client' */
import { block, branch, destroy_effect } from '../../reactivity/effects.js';
import { get_start, hydrate_nodes, hydrating } from '../hydration.js';
import { hydrate_next, hydrate_node, hydrating, set_hydrate_node } from '../hydration.js';
import { create_fragment_from_html } from '../reconciler.js';
import { assign_nodes } from '../template.js';
@ -11,9 +12,13 @@ import { assign_nodes } from '../template.js';
* @returns {void}
*/
export function html(anchor, get_value, svg, mathml) {
if (hydrating) {
hydrate_next();
}
var value = '';
/** @type {import('#client').Effect | null} */
/** @type {Effect | null} */
var effect;
block(() => {
@ -28,7 +33,12 @@ export function html(anchor, get_value, svg, mathml) {
effect = branch(() => {
if (hydrating) {
assign_nodes(get_start(), hydrate_nodes[hydrate_nodes.length - 1]);
var next = hydrate_node;
while (next.nodeType !== 8 || /** @type {Comment} */ (next).data !== '/html') {
next = /** @type {TemplateNode} */ (next.nextSibling);
}
assign_nodes(hydrate_node, set_hydrate_node(next));
return;
}
@ -46,8 +56,8 @@ export function html(anchor, get_value, svg, mathml) {
}
assign_nodes(
/** @type {import('#client').TemplateNode} */ (node.firstChild),
/** @type {import('#client').TemplateNode} */ (node.lastChild)
/** @type {TemplateNode} */ (node.firstChild),
/** @type {TemplateNode} */ (node.lastChild)
);
if (svg || mathml) {
@ -59,4 +69,8 @@ export function html(anchor, get_value, svg, mathml) {
}
});
});
if (hydrating) {
anchor = hydrate_node;
}
}

@ -17,7 +17,7 @@ export let hydrate_node;
/** @param {TemplateNode} node */
export function set_hydrate_node(node) {
hydrate_node = node;
return (hydrate_node = node);
}
/**

@ -108,7 +108,6 @@ export function ns_template(content, flags, ns = 'svg') {
return () => {
if (hydrating) {
assign_nodes(get_start(), null);
return hydrate_node;
}
@ -207,11 +206,8 @@ function run_scripts(node) {
}
}
/**
* @param {Text | Comment | Element} anchor
*/
/*#__NO_SIDE_EFFECTS__*/
export function text(anchor) {
export function text() {
if (!hydrating) {
var t = empty();
assign_nodes(t, t);

Loading…
Cancel
Save