Skip to content

Commit 7e5e462

Browse files
authored
feat: use short comments (#10899)
* use short comments * fix
1 parent 32b1824 commit 7e5e462

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

packages/svelte/src/compiler/phases/3-transform/server/transform-server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ const template_visitors = {
15211521
if (node.fallback) {
15221522
const fallback_stmts = create_block(node, node.fallback.nodes, context);
15231523
fallback_stmts.unshift(
1524-
b.stmt(b.assignment('+=', b.id('$$payload.out'), b.literal('<!--ssr:each_else-->')))
1524+
b.stmt(b.assignment('+=', b.id('$$payload.out'), b.literal('<!ssr:each_else>')))
15251525
);
15261526
state.template.push(
15271527
t_statement(
@@ -1549,14 +1549,14 @@ const template_visitors = {
15491549

15501550
const consequent = create_block(node, node.consequent.nodes, context);
15511551
consequent.unshift(
1552-
b.stmt(b.assignment('+=', b.id('$$payload.out'), b.literal('<!--ssr:if:true-->')))
1552+
b.stmt(b.assignment('+=', b.id('$$payload.out'), b.literal('<!ssr:if:true>')))
15531553
);
15541554

15551555
const alternate = node.alternate
15561556
? /** @type {import('estree').BlockStatement} */ (context.visit(node.alternate))
15571557
: b.block([]);
15581558
alternate.body.unshift(
1559-
b.stmt(b.assignment('+=', b.id('$$payload.out'), b.literal('<!--ssr:if:false-->')))
1559+
b.stmt(b.assignment('+=', b.id('$$payload.out'), b.literal('<!ssr:if:false>')))
15601560
);
15611561

15621562
state.template.push(

packages/svelte/src/internal/server/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ export function ensure_array_like(array_like_or_iterator) {
637637
/** @param {{ anchor: number }} payload */
638638
export function create_anchor(payload) {
639639
const depth = payload.anchor++;
640-
return `<!--ssr:${depth}-->`;
640+
return `<!ssr:${depth}>`;
641641
}
642642

643643
/** @returns {[() => false, (value: boolean) => void]} */

packages/svelte/tests/html_equal.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function normalize_html(
7777
try {
7878
const node = window.document.createElement('div');
7979
node.innerHTML = html
80-
.replace(/(<!--.*?-->)/g, preserveComments ? '$1' : '')
80+
.replace(/(<!(--)?.*?\2>)/g, preserveComments ? '$1' : '')
8181
.replace(/(data-svelte-h="[^"]+")/g, removeDataSvelte ? '' : '$1')
8282
.replace(/>[ \t\n\r\f]+</g, '><')
8383
.trim();
@@ -135,15 +135,15 @@ export function setup_html_equal(options = {}) {
135135
try {
136136
assert.deepEqual(
137137
withoutNormalizeHtml
138-
? normalize_new_line(actual)
138+
? normalize_new_line(actual.trim())
139139
.replace(/(\sdata-svelte-h="[^"]+")/g, options.removeDataSvelte ? '' : '$1')
140-
.replace(/(<!--.*?-->)/g, preserveComments !== false ? '$1' : '')
141-
: normalize_html(window, actual, { ...options, preserveComments }),
140+
.replace(/(<!(--)?.*?\2>)/g, preserveComments !== false ? '$1' : '')
141+
: normalize_html(window, actual.trim(), { ...options, preserveComments }),
142142
withoutNormalizeHtml
143-
? normalize_new_line(expected)
143+
? normalize_new_line(expected.trim())
144144
.replace(/(\sdata-svelte-h="[^"]+")/g, options.removeDataSvelte ? '' : '$1')
145-
.replace(/(<!--.*?-->)/g, preserveComments !== false ? '$1' : '')
146-
: normalize_html(window, expected, { ...options, preserveComments }),
145+
.replace(/(<!(--)?.*?\2>)/g, preserveComments !== false ? '$1' : '')
146+
: normalize_html(window, expected.trim(), { ...options, preserveComments }),
147147
message
148148
);
149149
} catch (e) {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<!--ssr:0-->
1+
<!ssr:0>
22
<title>Some Title</title>
33
<link rel="canonical" href="/">
44
<meta name="description" content="some description">
55
<meta name="keywords" content="some keywords">
6-
<!--ssr:0-->
6+
<!ssr:0>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!--ssr:0--><div>Just a dummy page.</div><!--ssr:0-->
1+
<!ssr:0><div>Just a dummy page.</div><!ssr:0>

0 commit comments

Comments
 (0)