mirror of https://github.com/sveltejs/svelte
fix: correctly tag private class state fields (#16132)
parent
e8a7c426d4
commit
f5a020d56b
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: correctly tag private class state fields
|
@ -0,0 +1,31 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
import { normalise_trace_logs } from '../../../helpers.js';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
test({ assert, target, logs }) {
|
||||
assert.deepEqual(normalise_trace_logs(logs), [
|
||||
{ log: 'effect' },
|
||||
{ log: '$state', highlighted: true },
|
||||
{ log: 'Counter.#count', highlighted: false },
|
||||
{ log: 0 }
|
||||
]);
|
||||
|
||||
logs.length = 0;
|
||||
|
||||
const button = target.querySelector('button');
|
||||
button?.click();
|
||||
flushSync();
|
||||
|
||||
assert.deepEqual(normalise_trace_logs(logs), [
|
||||
{ log: 'effect' },
|
||||
{ log: '$state', highlighted: true },
|
||||
{ log: 'Counter.#count', highlighted: false },
|
||||
{ log: 1 }
|
||||
]);
|
||||
}
|
||||
});
|
@ -0,0 +1,28 @@
|
||||
<script>
|
||||
class Counter {
|
||||
#count;
|
||||
|
||||
constructor() {
|
||||
this.#count = $state(0);
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this.#count;
|
||||
}
|
||||
|
||||
increment = () => {
|
||||
this.#count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
const counter = new Counter();
|
||||
|
||||
$effect(() => {
|
||||
$inspect.trace('effect');
|
||||
counter.count;
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={counter.increment}>
|
||||
clicks: {counter.count}
|
||||
</button>
|
Loading…
Reference in new issue