Skip to content

Commit fcdc698

Browse files
committed
fix: revert props legacy mode regression
#16270 removed a condition which seemed to keep passing the corresponding test, but it actually introduced a regression since the PROPS_IS_UPDATED is always set when accessors should be created, which is the case by default in legacy mode tests. Setting accessors to false in the test reveals the regression, so this reverts that part of the refactoring
1 parent 11ec907 commit fcdc698

File tree

2 files changed

+6
-3
lines changed
  • packages/svelte
    • src/internal/client/reactivity
    • tests/runtime-legacy/samples/prop-no-change

2 files changed

+6
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export function prop(props, key, flags, fallback) {
336336
}
337337

338338
// prop is never written to — we only need a getter
339-
if ((flags & PROPS_IS_UPDATED) === 0) {
339+
if (runes && (flags & PROPS_IS_UPDATED) === 0) {
340340
return getter;
341341
}
342342

@@ -362,8 +362,10 @@ export function prop(props, key, flags, fallback) {
362362
};
363363
}
364364

365-
// prop is written to, but there's no binding, which means we
366-
// create a derived that we can write to locally
365+
// Either prop is written to, but there's no binding, which means we
366+
// create a derived that we can write to locally.
367+
// Or we are in legacy mode where we always create a derived to replicate that
368+
// Svelte 4 did not trigger updates when a primitive value was updated to the same value.
367369
var d = ((flags & PROPS_IS_IMMUTABLE) !== 0 ? derived : derived_safe_equal)(getter);
368370

369371
// Capture the initial value if it's bindable

packages/svelte/tests/runtime-legacy/samples/prop-no-change/_config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { flushSync } from 'svelte';
22
import { test } from '../../test';
33

44
export default test({
5+
accessors: false,
56
test({ assert, logs, target }) {
67
assert.deepEqual(logs, ['primitive', 'object']);
78
target.querySelector('button')?.click();

0 commit comments

Comments
 (0)