Skip to content

fix(print): handle svelte:body and fix keyframe percentage double-printing#18234

Merged
dummdidumm merged 1 commit into
sveltejs:mainfrom
OfirHaf:fix/printer-svelte-body-and-keyframe-percentage
May 18, 2026
Merged

fix(print): handle svelte:body and fix keyframe percentage double-printing#18234
dummdidumm merged 1 commit into
sveltejs:mainfrom
OfirHaf:fix/printer-svelte-body-and-keyframe-percentage

Conversation

@OfirHaf

@OfirHaf OfirHaf commented May 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #18206 and fixes #18207 — both are printer bugs in packages/svelte/src/compiler/print/index.js.

Changes

Fix 1: svelte:body crashes the printer (#18206)

SvelteBody was missing from the visitor map, causing a crash with Error: Not implemented: SvelteBody. Added the handler (same one-liner pattern as SvelteDocument, SvelteHead, etc.) and added SvelteBody to the is_block_element check so whitespace is handled consistently.

Fix 2: Keyframe percent stops print as 0%% (#18207)

Percentage.value already includes the % sign (captured by /\d+(\.\d+)?%/y), but the printer was writing `${node.value}%` — appending a second %. Changed to context.write(node.value) to match the Nth printer pattern directly above it.

Also updated the existing style snapshot which had 50%% (the bug was silently baked in), and added dedicated test samples for both fixes.

Test plan

  • pnpm test print passes — existing style snapshot updated, two new samples added
  • svelte:body no longer throws Error: Not implemented: SvelteBody
  • @keyframes foo { 0% { ... } 100% { ... } } round-trips cleanly without double %

…nting

- Add SvelteBody visitor to the printer (fixes crash: 'Not implemented: SvelteBody')
- Add SvelteBody to is_block_element check for correct whitespace handling
- Fix Percentage printer writing node.value twice (node.value already includes %, printer was appending another %)
- Update existing style snapshot and add dedicated test samples for both fixes

Fixes sveltejs#18206, sveltejs#18207
@changeset-bot

changeset-bot Bot commented May 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 77620b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dummdidumm dummdidumm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@dummdidumm dummdidumm merged commit ca3f35b into sveltejs:main May 18, 2026
17 checks passed
@github-actions github-actions Bot mentioned this pull request May 18, 2026
dummdidumm pushed a commit that referenced this pull request May 18, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## svelte@5.55.8

### Patch Changes

- fix(print): handle `svelte:body` and fix keyframe percentage
double-printing
([#18234](#18234))

- fix: execute uninitialized derived even if it's destroyed
([#18228](#18228))

- fix: use named symbols everywhere
([#18238](#18238))

- fix: don't run teardown effects when deriveds are unfreezed
([#18227](#18227))

- fix: unset context synchronously in `run`
([#18236](#18236))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Printer cannot print css keyframes with percent stops correctly Printer cannot print svelte:body

2 participants