Skip to content

Commit eb7dd3c

Browse files
committed
fix: ensure $inspect.trace works correctly with null values
1 parent 7f8acb8 commit eb7dd3c

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

.changeset/rotten-ligers-agree.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: ensure $inspect.trace works correctly with null values

packages/svelte/src/internal/client/dev/tracing.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ function log_entry(signal, entry) {
5151
status !== 'clean'
5252
? 'color: CornflowerBlue; font-weight: bold'
5353
: 'color: grey; font-weight: bold',
54-
typeof value === 'object' && STATE_SYMBOL in value ? snapshot(value, true) : value
54+
typeof value === 'object' && value !== null && STATE_SYMBOL in value
55+
? snapshot(value, true)
56+
: value
5557
);
5658

5759
if (type === '$derived') {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { test, ok } from '../../test';
2+
3+
export default test({
4+
html: `<svg viewBox="0 0 16 16"><title></title><path d="M8 0C3.589 0 0 3.589 0 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm0 15c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7z"></path><path d="M11.146 5.388L6.982 9.552 4.839 7.409c-.195-.195-.512-.195-.707 0-.195.195-.195.512 0 .707l2.496 2.496c.195.195.512.195.707 0l4.518-4.518c.195-.195.195-.512 0-.707-.195-.195-.511-.195-.707.001z"></path></svg>`,
5+
test({ assert, target }) {
6+
const title = target.querySelector('title');
7+
ok(title);
8+
9+
assert.equal(title.namespaceURI, 'http://www.w3.org/2000/svg');
10+
}
11+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script>
2+
let title = 'Circle with checkmark';
3+
</script>
4+
5+
<svg viewBox="0 0 16 16" aria-hidden={title ? null : "true"}>
6+
{#if title}
7+
<title>{title}</title>
8+
{/if}
9+
<path d="M8 0C3.589 0 0 3.589 0 8s3.589 8 8 8 8-3.589 8-8-3.589-8-8-8zm0 15c-3.86 0-7-3.14-7-7s3.14-7 7-7 7 3.14 7 7-3.14 7-7 7z"></path>
10+
<path d="M11.146 5.388L6.982 9.552 4.839 7.409c-.195-.195-.512-.195-.707 0-.195.195-.195.512 0 .707l2.496 2.496c.195.195.512.195.707 0l4.518-4.518c.195-.195.195-.512 0-.707-.195-.195-.511-.195-.707.001z"></path>
11+
</svg>

0 commit comments

Comments
 (0)