mirror of https://github.com/sveltejs/svelte
fix(print): handle svelte:body and fix keyframe percentage double-printing (#18234)
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.pull/18239/head
parent
2bc3592eb1
commit
ca3f35bf7d
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix(print): handle `svelte:body` and fix keyframe percentage double-printing
|
||||
@ -0,0 +1,7 @@
|
||||
<style>
|
||||
@keyframes foo {
|
||||
0% { left: 0px; }
|
||||
50% { left: 50px; }
|
||||
100% { left: 100px; }
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,13 @@
|
||||
<style>
|
||||
@keyframes foo {
|
||||
0% {
|
||||
left: 0px;
|
||||
}
|
||||
50% {
|
||||
left: 50px;
|
||||
}
|
||||
100% {
|
||||
left: 100px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1 @@
|
||||
<svelte:body onmousemove={handleMousemove} />
|
||||
@ -0,0 +1 @@
|
||||
<svelte:body onmousemove={handleMousemove}></svelte:body>
|
||||
Loading…
Reference in new issue