Skip to content

Commit 06c5023

Browse files
committed
tweak behavior to be more inline with what we do in case of props for components in the template
1 parent 4347b30 commit 06c5023

File tree

2 files changed

+9
-6
lines changed
  • packages/svelte
    • src/internal/client/reactivity
    • tests/runtime-runes/samples/mount-props-updates

2 files changed

+9
-6
lines changed

packages/svelte/src/internal/client/reactivity/props.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ const spread_props_handler = {
215215
}
216216
},
217217
has(target, key) {
218-
if (key === STATE_SYMBOL) return false;
218+
// To prevent a false positive `is_entry_props` in the `prop` function
219+
if (key === STATE_SYMBOL || key === LEGACY_PROPS) return false;
219220

220221
for (let p of target.props) {
221222
if (is_function(p)) p = p();
@@ -297,7 +298,7 @@ export function prop(props, key, flags, fallback) {
297298

298299
var setter =
299300
get_descriptor(props, key)?.set ??
300-
(is_entry_props && bindable ? (v) => (props[key] = v) : undefined);
301+
(is_entry_props && bindable && key in props ? (v) => (props[key] = v) : undefined);
301302

302303
var fallback_value = /** @type {V} */ (fallback);
303304
var fallback_dirty = true;
@@ -318,7 +319,7 @@ export function prop(props, key, flags, fallback) {
318319
};
319320

320321
if (prop_value === undefined && fallback !== undefined) {
321-
if (setter && runes && !is_entry_props) {
322+
if (setter && runes) {
322323
e.props_invalid_value(key);
323324
}
324325

packages/svelte/tests/runtime-runes/samples/mount-props-updates/_config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ export default test({
55
test({ assert, target }) {
66
assert.htmlEqual(
77
target.innerHTML,
8-
// Even thought we're in runes mode, the buz fallback propagates back up in this case
8+
// The buz fallback does not propagate back up
99
`
10-
<button>reset</button> foo baz buz
10+
<button>reset</button> foo baz
1111
<div><button>update</button> foo bar baz buz</div>
1212
<div><button>update</button> foo bar baz buz</div>
1313
`
@@ -21,8 +21,10 @@ export default test({
2121
assert.htmlEqual(
2222
target.innerHTML,
2323
// bar is not set in the parent because it's a readonly property
24+
// baz is not set in the parent because while it's a bindable property,
25+
// it wasn't set initially so it's treated as a readonly proeprty
2426
`
25-
<button>reset</button> foo 3 4
27+
<button>reset</button> foo 3
2628
<div><button>update</button> 1 2 3 4</div>
2729
<div><button>update</button> 1 2 3 4</div>
2830
`

0 commit comments

Comments
 (0)