Skip to content

Commit

Permalink
fix: allow double hyphen css selector names (#15384)
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloricciuti authored Feb 24, 2025
1 parent c2ec0d9 commit 3d59e84
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-pants-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: allow double hyphen css selector names
4 changes: 2 additions & 2 deletions packages/svelte/src/compiler/phases/1-parse/read/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,15 @@ function read_attribute_value(parser) {
}

/**
* https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
* https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
* @param {Parser} parser
*/
function read_identifier(parser) {
const start = parser.index;

let identifier = '';

if (parser.match('--') || parser.match_regex(REGEX_LEADING_HYPHEN_OR_DIGIT)) {
if (parser.match_regex(REGEX_LEADING_HYPHEN_OR_DIGIT)) {
e.css_expected_identifier(start);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/svelte/tests/css/samples/double-hyphen/expected.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

.--foo.svelte-xyz {
color: red;
}
7 changes: 7 additions & 0 deletions packages/svelte/tests/css/samples/double-hyphen/input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="--foo"></div>

<style>
.--foo {
color: red;
}
</style>

0 comments on commit 3d59e84

Please sign in to comment.