mirror of https://github.com/sveltejs/svelte
fix: better `$inspect.trace()` output (#16131)
* remove code thatcan't be reached and would error if it could
* tidy up types, fix duplication
* this seems needless
* better naming
* tidy up
* reorder
* this code doesn't appear to do anything useful, and no tests fail without it
* unused
* WIP
* revert part of #14811. it makes no sense to show the initial value, it just makes things inconsistent with deriveds. personally i find it more confusing anyway
* explanatory comment on both sides
* make things a bit more self-explanatory
* simplify
* missing type
* only log UpdatedAt for dirty signals
* changeset
* lint
* Revert "unused"
This reverts commit a95b625800
.
* complete revert
* ok it works now
pull/16128/head
parent
292af8d38a
commit
438349eb88
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: better `$inspect.trace()` output
|
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
let { entry } = $props();
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
$inspect.trace('effect');
|
||||||
|
entry;
|
||||||
|
});
|
||||||
|
</script>
|
@ -0,0 +1,40 @@
|
|||||||
|
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: 'array', highlighted: false },
|
||||||
|
{ log: [{ id: 1, hi: true }] },
|
||||||
|
// this _doesn't_ appear in the browser, but it does appear during tests
|
||||||
|
// and i cannot for the life of me figure out why. this does at least
|
||||||
|
// test that we don't log `array[0].id` etc
|
||||||
|
{ log: '$state', highlighted: true },
|
||||||
|
{ log: 'array[0]', highlighted: false },
|
||||||
|
{ log: { id: 1, hi: true } }
|
||||||
|
]);
|
||||||
|
|
||||||
|
logs.length = 0;
|
||||||
|
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
button?.click();
|
||||||
|
flushSync();
|
||||||
|
|
||||||
|
assert.deepEqual(normalise_trace_logs(logs), [
|
||||||
|
{ log: 'effect' },
|
||||||
|
{ log: '$state', highlighted: true },
|
||||||
|
{ log: 'array', highlighted: false },
|
||||||
|
{ log: [{ id: 1, hi: false }] },
|
||||||
|
{ log: '$state', highlighted: false },
|
||||||
|
{ log: 'array[0]', highlighted: false },
|
||||||
|
{ log: { id: 1, hi: false } }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
import Entry from './Entry.svelte';
|
||||||
|
|
||||||
|
let array = $state([{ id: 1, hi: true }]);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => array = [{ id: 1, hi: false}]}>update</button>
|
||||||
|
|
||||||
|
{#each array as entry (entry.id)}
|
||||||
|
<Entry {entry} />
|
||||||
|
{/each}
|
Loading…
Reference in new issue