Skip to content

Commit 2db5bcc

Browse files
authored
chore: default params for html blocks (#15778)
* chore: default params for html blocks * fix * changeset * update test
1 parent ea4843c commit 2db5bcc

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

.changeset/chatty-apples-flash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
chore: default params for html blocks

packages/svelte/src/compiler/phases/3-transform/client/visitors/HtmlTag.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ import * as b from '../../../../utils/builders.js';
1111
export function HtmlTag(node, context) {
1212
context.state.template.push('<!>');
1313

14-
// push into init, so that bindings run afterwards, which might trigger another run and override hydration
15-
context.state.init.push(
16-
b.stmt(
17-
b.call(
18-
'$.html',
19-
context.state.node,
20-
b.thunk(/** @type {Expression} */ (context.visit(node.expression))),
21-
b.literal(context.state.metadata.namespace === 'svg'),
22-
b.literal(context.state.metadata.namespace === 'mathml'),
23-
is_ignored(node, 'hydration_html_changed') && b.true
24-
)
14+
const expression = /** @type {Expression} */ (context.visit(node.expression));
15+
16+
const is_svg = context.state.metadata.namespace === 'svg';
17+
const is_mathml = context.state.metadata.namespace === 'mathml';
18+
19+
const statement = b.stmt(
20+
b.call(
21+
'$.html',
22+
context.state.node,
23+
b.thunk(expression),
24+
is_svg && b.true,
25+
is_mathml && b.true,
26+
is_ignored(node, 'hydration_html_changed') && b.true
2527
)
2628
);
29+
30+
// push into init, so that bindings run afterwards, which might trigger another run and override hydration
31+
context.state.init.push(statement);
2732
}

packages/svelte/src/internal/client/dom/blocks/html.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ function check_hash(element, server_hash, value) {
3434
/**
3535
* @param {Element | Text | Comment} node
3636
* @param {() => string} get_value
37-
* @param {boolean} svg
38-
* @param {boolean} mathml
37+
* @param {boolean} [svg]
38+
* @param {boolean} [mathml]
3939
* @param {boolean} [skip_warning]
4040
* @returns {void}
4141
*/
42-
export function html(node, get_value, svg, mathml, skip_warning) {
42+
export function html(node, get_value, svg = false, mathml = false, skip_warning = false) {
4343
var anchor = node;
4444

4545
var value = '';

packages/svelte/tests/snapshot/samples/skip-static-subtree/_expected/client/index.svelte.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function Skip_static_subtree($$anchor, $$props) {
1313

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

16-
$.html(node, () => $$props.content, false, false);
16+
$.html(node, () => $$props.content);
1717
$.next(14);
1818
$.reset(main);
1919

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy