Skip to content

Commit e4ee0f6

Browse files
committed
add test
1 parent 65ef40a commit e4ee0f6

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/DebugTag.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import * as b from '../../../../utils/builders.js';
99
*/
1010
export function DebugTag(node, context) {
1111
const object = b.object(
12-
node.identifiers.map((identifier) =>
13-
b.prop(
12+
node.identifiers.map((identifier) => {
13+
const visited = b.call('$.snapshot', /** @type {Expression} */ (context.visit(identifier)));
14+
15+
return b.prop(
1416
'init',
1517
identifier,
16-
b.call('$.snapshot', /** @type {Expression} */ (context.visit(identifier)))
17-
)
18-
)
18+
context.state.analysis.runes ? visited : b.call('$.untrack', b.thunk(visited))
19+
);
20+
})
1921
);
2022

2123
const call = b.call('console.log', object);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
compileOptions: {
6+
dev: true
7+
},
8+
9+
test({ assert, target, logs }) {
10+
const b1 = target.querySelector('button');
11+
b1?.click();
12+
flushSync();
13+
b1?.click();
14+
flushSync();
15+
16+
assert.deepEqual(logs, [
17+
{ count: { current: 0 } },
18+
{ count: { current: 1 } },
19+
{ count: { current: 2 } }
20+
]);
21+
}
22+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script>
2+
let count = $state({ current: 0 });
3+
</script>
4+
5+
{@debug count}
6+
7+
<button onclick={()=> count.current++}>+</button>

0 commit comments

Comments
 (0)