Skip to content

Commit 3f01290

Browse files
committed
allow comments, remove trim
1 parent 241c629 commit 3f01290

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

packages/svelte/src/compiler/phases/1-parse/read/style.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function read_selector_list(parser, inside_pseudo_class = false) {
153153
/** @type {import('#compiler').Css.Selector[]} */
154154
const children = [];
155155

156-
parser.allow_whitespace();
156+
allow_comment_or_whitespace(parser);
157157

158158
const start = parser.index;
159159

@@ -288,9 +288,10 @@ function read_selector(parser, inside_pseudo_class = false) {
288288
});
289289
} else if (inside_pseudo_class && parser.match_regex(REGEX_NTH_OF)) {
290290
// nth of matcher must come before combinator matcher to prevent collision else the '+' in '+2n-1' would be parsed as a combinator
291+
291292
children.push({
292293
type: 'Nth',
293-
value: /** @type {string} */ (parser.read(REGEX_NTH_OF)?.trimEnd()), // in case it ends with 'of'
294+
value: /**@type {string} */ (parser.read(REGEX_NTH_OF)),
294295
start,
295296
end: parser.index
296297
});

packages/svelte/tests/parser-modern/samples/css-nth-syntax/output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"children": [
104104
{
105105
"type": "Nth",
106-
"value": "-n + 3 of",
106+
"value": "-n + 3 of ",
107107
"start": 130,
108108
"end": 140
109109
},

packages/svelte/tests/parser-modern/samples/css-pseudo-classes/input.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
::slotted(.content) {
1616
color: red;
1717
}
18-
:is(
19-
button,
18+
:is( /*button*/
19+
button, /*p after h1*/
2020
h1 + p
2121
){
2222
color: red;

packages/svelte/tests/parser-modern/samples/css-pseudo-classes/output.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"css": {
33
"type": "Style",
44
"start": 0,
5-
"end": 360,
5+
"end": 386,
66
"attributes": [],
77
"children": [
88
{
@@ -231,90 +231,90 @@
231231
"prelude": {
232232
"type": "SelectorList",
233233
"start": 306,
234-
"end": 333,
234+
"end": 359,
235235
"children": [
236236
{
237237
"type": "Selector",
238238
"start": 306,
239-
"end": 333,
239+
"end": 359,
240240
"children": [
241241
{
242242
"type": "PseudoClassSelector",
243243
"name": "is",
244244
"args": {
245245
"type": "SelectorList",
246-
"start": 313,
247-
"end": 329,
246+
"start": 324,
247+
"end": 355,
248248
"children": [
249249
{
250250
"type": "Selector",
251-
"start": 313,
252-
"end": 319,
251+
"start": 324,
252+
"end": 330,
253253
"children": [
254254
{
255255
"type": "TypeSelector",
256256
"name": "button",
257-
"start": 313,
258-
"end": 319
257+
"start": 324,
258+
"end": 330
259259
}
260260
]
261261
},
262262
{
263263
"type": "Selector",
264-
"start": 323,
265-
"end": 329,
264+
"start": 349,
265+
"end": 355,
266266
"children": [
267267
{
268268
"type": "TypeSelector",
269269
"name": "h1",
270-
"start": 323,
271-
"end": 325
270+
"start": 349,
271+
"end": 351
272272
},
273273
{
274274
"type": "Combinator",
275275
"name": "+",
276-
"start": 326,
277-
"end": 327
276+
"start": 352,
277+
"end": 353
278278
},
279279
{
280280
"type": "TypeSelector",
281281
"name": "p",
282-
"start": 328,
283-
"end": 329
282+
"start": 354,
283+
"end": 355
284284
}
285285
]
286286
}
287287
]
288288
},
289289
"start": 306,
290-
"end": 333
290+
"end": 359
291291
}
292292
]
293293
}
294294
]
295295
},
296296
"block": {
297297
"type": "Block",
298-
"start": 333,
299-
"end": 351,
298+
"start": 359,
299+
"end": 377,
300300
"children": [
301301
{
302302
"type": "Declaration",
303-
"start": 337,
304-
"end": 347,
303+
"start": 363,
304+
"end": 373,
305305
"property": "color",
306306
"value": "red"
307307
}
308308
]
309309
},
310310
"start": 306,
311-
"end": 351
311+
"end": 377
312312
}
313313
],
314314
"content": {
315315
"start": 7,
316-
"end": 352,
317-
"styles": "\n /* test that all these are parsed correctly */\n\t::view-transition-old(x-y) {\n\t\tcolor: red;\n }\n\t:global(::view-transition-old(x-y)) {\n\t\tcolor: red;\n }\n\t::highlight(rainbow-color-1) {\n\t\tcolor: red;\n\t}\n\tcustom-element::part(foo) {\n\t\tcolor: red;\n\t}\n\t::slotted(.content) {\n\t\tcolor: red;\n\t}\n\t:is(\n\t\tbutton,\n\t\th1 + p\n\t\t){\n\t\tcolor: red;\n\t}\n"
316+
"end": 378,
317+
"styles": "\n /* test that all these are parsed correctly */\n\t::view-transition-old(x-y) {\n\t\tcolor: red;\n }\n\t:global(::view-transition-old(x-y)) {\n\t\tcolor: red;\n }\n\t::highlight(rainbow-color-1) {\n\t\tcolor: red;\n\t}\n\tcustom-element::part(foo) {\n\t\tcolor: red;\n\t}\n\t::slotted(.content) {\n\t\tcolor: red;\n\t}\n\t:is( /*button*/\n\t\tbutton, /*p after h1*/\n\t\th1 + p\n\t\t){\n\t\tcolor: red;\n\t}\n"
318318
}
319319
},
320320
"js": [],

0 commit comments

Comments
 (0)