Description
Describe the bug
Sorry in advance, but I might be bringing a PITA with comments, again.
I noticed while working on updating svelte-ast-print
, I've had inline snapshots mismatch (thanks Vitest!).
There was a bug which I've overlooked before and noticed that something was off. I was able to narrow that there's a parsing difference between version svelte@5.0.0-next.190
and svelte@5.0.0-next.191
. Regardless, both versions parse it wrongly, including the latest one.
Possibly related PR: #12471
Piece of input inside the <script>
tag that gets parsed wrong:
beforeUpdate(() => {
// determine whether we should auto-scroll
// once the DOM is updated...
});
afterUpdate(() => {
// ...the DOM is now in sync with the data
});
|
|
---|---|
- beforeUpdate(() => {
- // determine whether we should auto-scroll
+ beforeUpdate(() => {}); // determine whether we should auto-scroll
- // once the DOM is updated...
+ // once the DOM is updated...
- });
-
- afterUpdate(() => {
- // ...the DOM is now in sync with the data
- });
+ afterUpdate(() => {}); // ...the DOM is now in sync with the data |
- beforeUpdate(() => {
+ beforeUpdate(() => {});
- // determine whether we should auto-scroll
+ // determine whether we should auto-scroll
- // once the DOM is updated...
+ // once the DOM is updated...
- });
-
- afterUpdate(() => {
+ afterUpdate(() => {});
+
- // ...the DOM is now in sync with the data
+ // ...the DOM is now in sync with the data
- });
- |
Below I will provide a simple reproduction where you can see that the comment inside the callback scope of beforeUpdate()
gets wrongly parsed as trailingComments
.
Reproduction
Logs
No response
System Info
next
Severity
annoyance