Skip to content

Commit 99f0464

Browse files
committed
merge
2 parents c8ab9e6 + 2f68131 commit 99f0464

File tree

2 files changed

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

2 files changed

+6
-7
lines changed

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

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

366366
// prop is never written to — we only need a getter
367-
if ((flags & PROPS_IS_UPDATED) === 0) {
367+
if (runes && (flags & PROPS_IS_UPDATED) === 0) {
368368
return getter;
369369
}
370370

@@ -390,8 +390,10 @@ export function prop(props, key, flags, fallback) {
390390
};
391391
}
392392

393-
// prop is written to, but there's no binding, which means we
394-
// create a derived that we can write to locally
393+
// Either prop is written to, but there's no binding, which means we
394+
// create a derived that we can write to locally.
395+
// Or we are in legacy mode where we always create a derived to replicate that
396+
// Svelte 4 did not trigger updates when a primitive value was updated to the same value.
395397
var overridden = false;
396398

397399
var d = ((flags & PROPS_IS_IMMUTABLE) !== 0 ? derived : derived_safe_equal)(() => {
@@ -404,10 +406,6 @@ export function prop(props, key, flags, fallback) {
404406

405407
var parent_effect = /** @type {Effect} */ (active_effect);
406408

407-
if (!parent_effect) {
408-
console.trace();
409-
}
410-
411409
return function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
412410
if (arguments.length > 0) {
413411
const new_value = mutation ? get(d) : runes && bindable ? proxy(value) : value;

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)