Skip to content

Commit 8733a5d

Browse files
committed
Merge branch 'main' into async
2 parents 6e1c89f + f5a020d commit 8733a5d

File tree

5 files changed

+65
-2
lines changed

5 files changed

+65
-2
lines changed

.changeset/three-steaks-wash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: correctly tag private class state fields

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function ClassBody(node, context) {
7878
? /** @type {CallExpression} */ (context.visit(definition.value, child_state))
7979
: undefined;
8080

81-
if (dev) {
81+
if (dev && field.node === definition) {
8282
value = b.call('$.tag', value, b.literal(`${declaration.id?.name ?? '[class]'}.${name}`));
8383
}
8484

packages/svelte/tests/runtime-runes/samples/flush-sync-no-scheduled/_config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default test({
55
const btn = target.querySelector('button');
66
const main = target.querySelector('main');
77
ok(main);
8-
console.log(main.innerHTML);
98
assert.htmlEqual(main.innerHTML, `<div>true</div>`);
109
// we don't want to use flush sync (or tick that use it inside) since we are testing that calling `flushSync` once
1110
// when there are no scheduled effects does not cause reactivity to break
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
import { normalise_trace_logs } from '../../../helpers.js';
4+
5+
export default test({
6+
compileOptions: {
7+
dev: true
8+
},
9+
10+
test({ assert, target, logs }) {
11+
assert.deepEqual(normalise_trace_logs(logs), [
12+
{ log: 'effect' },
13+
{ log: '$state', highlighted: true },
14+
{ log: 'Counter.#count', highlighted: false },
15+
{ log: 0 }
16+
]);
17+
18+
logs.length = 0;
19+
20+
const button = target.querySelector('button');
21+
button?.click();
22+
flushSync();
23+
24+
assert.deepEqual(normalise_trace_logs(logs), [
25+
{ log: 'effect' },
26+
{ log: '$state', highlighted: true },
27+
{ log: 'Counter.#count', highlighted: false },
28+
{ log: 1 }
29+
]);
30+
}
31+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script>
2+
class Counter {
3+
#count;
4+
5+
constructor() {
6+
this.#count = $state(0);
7+
}
8+
9+
get count() {
10+
return this.#count;
11+
}
12+
13+
increment = () => {
14+
this.#count += 1;
15+
}
16+
}
17+
18+
const counter = new Counter();
19+
20+
$effect(() => {
21+
$inspect.trace('effect');
22+
counter.count;
23+
});
24+
</script>
25+
26+
<button onclick={counter.increment}>
27+
clicks: {counter.count}
28+
</button>

0 commit comments

Comments
 (0)