Skip to content

Commit 6d2f1a4

Browse files
fix: allow comments after last selector in css (#11723)
Fixes #11721
1 parent 0128df3 commit 6d2f1a4

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

.changeset/clever-maps-travel.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: allow comments after last selector in css

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function read_selector_list(parser, inside_pseudo_class = false) {
139139

140140
const end = parser.index;
141141

142-
parser.allow_whitespace();
142+
allow_comment_or_whitespace(parser);
143143

144144
if (inside_pseudo_class ? parser.match(')') : parser.match('{')) {
145145
return {
@@ -324,7 +324,7 @@ function read_selector(parser, inside_pseudo_class = false) {
324324
}
325325

326326
const index = parser.index;
327-
parser.allow_whitespace();
327+
allow_comment_or_whitespace(parser);
328328

329329
if (parser.match(',') || (inside_pseudo_class ? parser.match(')') : parser.match('{'))) {
330330
// rewind, so we know whether to continue building the selector list
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
.foo.svelte-xyz, /* some comment */
3+
.bar.svelte-xyz /* some other comment */
4+
{
5+
color: red;
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="foo">foo</div>
2+
<div class="bar">bar</div>
3+
4+
<style>
5+
.foo, /* some comment */
6+
.bar /* some other comment */
7+
{
8+
color: red;
9+
}
10+
</style>

0 commit comments

Comments
 (0)