mirror of https://github.com/sveltejs/svelte
fix: skip block comments in read_value to prevent apostrophe parsing error (#18153)
Fixes #18134. ## Problem `read_value()` in `packages/svelte/src/compiler/phases/1-parse/read/style.js` has no logic to skip CSS block comments (`/* ... */`). When the parser encounters an apostrophe inside a comment, it sets `quote_mark = "'"` — treating it as the start of a string literal — then never finds a matching closing quote, and ultimately throws `unexpected_eof` at the end of the style block. Minimal repro: ```svelte <style> /* it's a comment */ .foo { color: red; } </style> ``` → `Error: Unexpected end of input` ## Fix Add a `/* ... */` skip path inside the `read_value` loop, mirroring the same pattern already used in `allow_comment_or_whitespace`. When `/*` is detected outside a string or url context, the parser advances past the entire comment without adding its content to the value string. --------- Co-authored-by: Dor Alagem <doralagem@MacBook-Pro-sl-Dor.local> Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/18163/head
parent
ada3076967
commit
69b4c9f561
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ignore comments when reading CSS values
|
||||
@ -0,0 +1,4 @@
|
||||
|
||||
p.svelte-xyz {
|
||||
padding: 0 /* it's a comment */ 1em;
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<p>red</p>
|
||||
|
||||
<style>
|
||||
p {
|
||||
padding: 0 /* it's a comment */ 1em;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in new issue