Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-bags-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: correctly reflect readonly proxy marker
8 changes: 6 additions & 2 deletions packages/svelte/src/internal/client/proxy/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ const handler = {
},

get(target, prop, receiver) {
if (DEV && prop === READONLY_SYMBOL) return target[READONLY_SYMBOL];

if (DEV && prop === READONLY_SYMBOL) {
return Reflect.get(target, READONLY_SYMBOL);
}
const metadata = target[STATE_SYMBOL];
let s = metadata.s.get(prop);

Expand Down Expand Up @@ -184,6 +185,9 @@ const handler = {
},

has(target, prop) {
if (DEV && prop === READONLY_SYMBOL) {
return Reflect.has(target, READONLY_SYMBOL);
}
if (prop === STATE_SYMBOL) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script>
import Component2 from './Component2.svelte';
const {state} = $props();

function render(state) {
return state
}
</script>

<Component2 state={render(state)} />

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
const {state} = $props();
</script>

{state}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { test } from '../../test';

export default test({
compileOptions: {
dev: true
},
async test({ assert, target }) {
const btn = target.querySelector('button');

await btn?.click();
assert.htmlEqual(target.innerHTML, `<button></button>\n[object Object]`);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
import Component from './Component.svelte';

let state = $state();
</script>

<button onclick={() => {
state = {}
}}></button>
{#if state}
<Component state={state} />
{/if}