Skip to content

Commit 696b692

Browse files
authored
fix: revert shorthand ssr comments (#10980)
* fix: revert shorthand ssr comments * tests * add changeset
1 parent ef0191a commit 696b692

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

.changeset/serious-poems-brake.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+
fix: revert SSR shorthand comments

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ export function element(payload, tag, attributes_fn, children_fn) {
161161

162162
if (!VoidElements.has(tag)) {
163163
if (tag !== 'textarea') {
164-
payload.out += '<![>';
164+
payload.out += '<!--[-->';
165165
}
166166
children_fn();
167167
if (tag !== 'textarea') {
168-
payload.out += '<!]>';
168+
payload.out += '<!--]-->';
169169
}
170170
payload.out += `</${tag}>`;
171171
}
@@ -187,7 +187,7 @@ export function render(component, options) {
187187

188188
const prev_on_destroy = on_destroy;
189189
on_destroy = [];
190-
payload.out += '<![>';
190+
payload.out += '<!--[-->';
191191

192192
if (options.context) {
193193
push();
@@ -200,14 +200,14 @@ export function render(component, options) {
200200
pop();
201201
}
202202

203-
payload.out += '<!]>';
203+
payload.out += '<!--]-->';
204204
for (const cleanup of on_destroy) cleanup();
205205
on_destroy = prev_on_destroy;
206206

207207
return {
208208
head:
209209
payload.head.out || payload.head.title
210-
? payload.head.title + '<![>' + payload.head.out + '<!]>'
210+
? payload.head.title + '<!--[-->' + payload.head.out + '<!--]-->'
211211
: '',
212212
html: payload.out
213213
};
@@ -271,15 +271,15 @@ export function attr(name, value, boolean) {
271271
export function css_props(payload, is_html, props, component) {
272272
const styles = style_object_to_string(props);
273273
if (is_html) {
274-
payload.out += `<div style="display: contents; ${styles}"><![>`;
274+
payload.out += `<div style="display: contents; ${styles}"><!--[-->`;
275275
} else {
276-
payload.out += `<g style="${styles}"><![>`;
276+
payload.out += `<g style="${styles}"><!--[-->`;
277277
}
278278
component();
279279
if (is_html) {
280-
payload.out += `<!]></div>`;
280+
payload.out += `<!--]--></div>`;
281281
} else {
282-
payload.out += `<!]></g>`;
282+
payload.out += `<!--]--></g>`;
283283
}
284284
}
285285

packages/svelte/tests/parser-modern/samples/comment-before-script/output.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"column": 0
4545
}
4646
},
47-
"leadingComments": [{ "type": "Line", "value": "should not error out" }],
4847
"body": [
4948
{
5049
"type": "VariableDeclaration",
@@ -127,7 +126,13 @@
127126
"kind": "let"
128127
}
129128
],
130-
"sourceType": "module"
129+
"sourceType": "module",
130+
"leadingComments": [
131+
{
132+
"type": "Line",
133+
"value": "should not error out"
134+
}
135+
]
131136
}
132137
}
133138
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<![><div>Just a dummy page.</div><!]>
1+
<!--[--><div>Just a dummy page.</div><!--]-->

0 commit comments

Comments
 (0)