Skip to content

chore: default params for html blocks #15778

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Merged
merged 4 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chatty-apples-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

chore: default params for html blocks
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ import * as b from '../../../../utils/builders.js';
export function HtmlTag(node, context) {
context.state.template.push('<!>');

// push into init, so that bindings run afterwards, which might trigger another run and override hydration
context.state.init.push(
b.stmt(
b.call(
'$.html',
context.state.node,
b.thunk(/** @type {Expression} */ (context.visit(node.expression))),
b.literal(context.state.metadata.namespace === 'svg'),
b.literal(context.state.metadata.namespace === 'mathml'),
is_ignored(node, 'hydration_html_changed') && b.true
)
const expression = /** @type {Expression} */ (context.visit(node.expression));

const is_svg = context.state.metadata.namespace === 'svg';
const is_mathml = context.state.metadata.namespace === 'mathml';

const statement = b.stmt(
b.call(
'$.html',
context.state.node,
b.thunk(expression),
is_svg && b.true,
is_mathml && 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);
}
6 changes: 3 additions & 3 deletions packages/svelte/src/internal/client/dom/blocks/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ function check_hash(element, server_hash, value) {
/**
* @param {Element | Text | Comment} node
* @param {() => string} get_value
* @param {boolean} svg
* @param {boolean} mathml
* @param {boolean} [svg]
* @param {boolean} [mathml]
* @param {boolean} [skip_warning]
* @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 value = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function Skip_static_subtree($$anchor, $$props) {

var node = $.sibling(h1, 10);

$.html(node, () => $$props.content, false, false);
$.html(node, () => $$props.content);
$.next(14);
$.reset(main);

Expand Down