fix: revert props legacy mode regression (#16279)

#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
pull/16276/head
Simon H 2 months ago committed by GitHub
parent 11ec907fd5
commit 2f68131e9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -336,7 +336,7 @@ export function prop(props, key, flags, fallback) {
}
// prop is never written to — we only need a getter
if ((flags & PROPS_IS_UPDATED) === 0) {
if (runes && (flags & PROPS_IS_UPDATED) === 0) {
return getter;
}
@ -362,8 +362,10 @@ export function prop(props, key, flags, fallback) {
};
}
// prop is written to, but there's no binding, which means we
// create a derived that we can write to locally
// Either prop is written to, but there's no binding, which means we
// create a derived that we can write to locally.
// Or we are in legacy mode where we always create a derived to replicate that
// Svelte 4 did not trigger updates when a primitive value was updated to the same value.
var d = ((flags & PROPS_IS_IMMUTABLE) !== 0 ? derived : derived_safe_equal)(getter);
// Capture the initial value if it's bindable

@ -2,6 +2,7 @@ import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
accessors: false,
test({ assert, logs, target }) {
assert.deepEqual(logs, ['primitive', 'object']);
target.querySelector('button')?.click();

Loading…
Cancel
Save