chore: default params for html blocks (#15778)

* chore: default params for html blocks

* fix

* changeset

* update test
pull/15779/head
Rich Harris 5 months ago committed by GitHub
parent ea4843c5ad
commit 2db5bccde3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
chore: default params for html blocks

@ -11,17 +11,22 @@ import * as b from '../../../../utils/builders.js';
export function HtmlTag(node, context) { export function HtmlTag(node, context) {
context.state.template.push('<!>'); context.state.template.push('<!>');
// push into init, so that bindings run afterwards, which might trigger another run and override hydration const expression = /** @type {Expression} */ (context.visit(node.expression));
context.state.init.push(
b.stmt( const is_svg = context.state.metadata.namespace === 'svg';
const is_mathml = context.state.metadata.namespace === 'mathml';
const statement = b.stmt(
b.call( b.call(
'$.html', '$.html',
context.state.node, context.state.node,
b.thunk(/** @type {Expression} */ (context.visit(node.expression))), b.thunk(expression),
b.literal(context.state.metadata.namespace === 'svg'), is_svg && b.true,
b.literal(context.state.metadata.namespace === 'mathml'), is_mathml && b.true,
is_ignored(node, 'hydration_html_changed') && b.true is_ignored(node, 'hydration_html_changed') && b.true
) )
)
); );
// push into init, so that bindings run afterwards, which might trigger another run and override hydration
context.state.init.push(statement);
} }

@ -34,12 +34,12 @@ function check_hash(element, server_hash, value) {
/** /**
* @param {Element | Text | Comment} node * @param {Element | Text | Comment} node
* @param {() => string} get_value * @param {() => string} get_value
* @param {boolean} svg * @param {boolean} [svg]
* @param {boolean} mathml * @param {boolean} [mathml]
* @param {boolean} [skip_warning] * @param {boolean} [skip_warning]
* @returns {void} * @returns {void}
*/ */
export function html(node, get_value, svg, mathml, skip_warning) { export function html(node, get_value, svg = false, mathml = false, skip_warning = false) {
var anchor = node; var anchor = node;
var value = ''; var value = '';

@ -13,7 +13,7 @@ export default function Skip_static_subtree($$anchor, $$props) {
var node = $.sibling(h1, 10); var node = $.sibling(h1, 10);
$.html(node, () => $$props.content, false, false); $.html(node, () => $$props.content);
$.next(14); $.next(14);
$.reset(main); $.reset(main);

Loading…
Cancel
Save