Skip to content

Svelte CSS parser fails on apostrophe in CSS block comment with Unexpected end of input #18134

@johannesmutter

Description

@johannesmutter

Describe the bug

In a .svelte component <style> block, a CSS block comment containing an apostrophe (') can break Svelte’s CSS parsing and produce:

Unexpected end of input

The error is reported at the end of the style block (</style>), even though CSS braces/parens are balanced.

This is not a general comment issue: single-line and multi-line CSS comments parse fine unless they include this apostrophe case.

Expected behavior

Apostrophes inside CSS block comments should be treated as plain comment text and never affect parsing.

Actual behavior

Svelte reports:

Unexpected end of input

at the end of the <style> block.

Reproduction

Minimal reproduction

<style>
	.foo {
		left: min(
			calc(1px),
			/* across rows (so the marker ends at row 1's right edge). Disabled */
			calc(2px)
		);
	}
</style>

If I change 1's to 1s (remove apostrophe), parsing succeeds.

System Info

- Svelte: `5.53.12`
- `svelte-check`: `4.4.5`
- `@sveltejs/kit`: `2.55.0`
- Node: `v22.17.1`
- npm: `11.6.2`
- OS: macOS (Darwin `25.4.0`)

Additional context

  • Both single-line and multi-line CSS comments work in this file.
  • The failure is tied to the apostrophe character in comment content (e.g. 1's).
  • Error location points to style EOF, not the comment line.

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    cssStuff related to Svelte's built-in CSS handling

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions