mirror of https://github.com/sveltejs/svelte
fix: deeply unstate objects passed to inspect (#10056)
When doing `$inspect({ x, y })`, both `x` and `y` are now unstated if they are signals, compared to before where `unstate` was only called on the top level object, leaving the proxies in place which results in a worse debugging experience. Also improved typings which makes it easier to find related code paths.pull/10052/head
parent
e46a71e8a3
commit
8a8505928e
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: deeply unstate objects passed to inspect
|
@ -0,0 +1,40 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {any[]}
|
||||||
|
*/
|
||||||
|
let log;
|
||||||
|
/**
|
||||||
|
* @type {typeof console.log}}
|
||||||
|
*/
|
||||||
|
let original_log;
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
compileOptions: {
|
||||||
|
dev: true
|
||||||
|
},
|
||||||
|
before_test() {
|
||||||
|
log = [];
|
||||||
|
original_log = console.log;
|
||||||
|
console.log = (...v) => {
|
||||||
|
log.push(...v);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
after_test() {
|
||||||
|
console.log = original_log;
|
||||||
|
},
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const [b1] = target.querySelectorAll('button');
|
||||||
|
b1.click();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
assert.deepEqual(log, [
|
||||||
|
'init',
|
||||||
|
{ x: { count: 0 } },
|
||||||
|
[{ count: 0 }],
|
||||||
|
'update',
|
||||||
|
{ x: { count: 1 } },
|
||||||
|
[{ count: 1 }]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
let x = $state({count: 0});
|
||||||
|
|
||||||
|
$inspect({x}, [x]);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={() => x.count++}>{x.count}</button>
|
Loading…
Reference in new issue