-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: deeply unstate objects passed to inspect
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.
- Loading branch information
1 parent
e46a71e
commit e33da20
Showing
5 changed files
with
92 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: deeply unstate objects passed to inspect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/svelte/tests/runtime-runes/samples/inspect-nested-state/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }] | ||
]); | ||
} | ||
}); |
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/runtime-runes/samples/inspect-nested-state/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
let x = $state({count: 0}); | ||
$inspect({x}, [x]); | ||
</script> | ||
|
||
<button on:click={() => x.count++}>{x.count}</button> |