Skip to content

Commit 3556152

Browse files
committed
back to original plan
1 parent 1c0bfc3 commit 3556152

File tree

3 files changed

+11
-41
lines changed

3 files changed

+11
-41
lines changed

.changeset/nasty-pigs-lay.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'svelte': patch
33
---
44

5-
fix: alter heuristic for reading data eagerly in props handling
5+
fix: when re-connecting unowned deriveds, remove their unowned flag

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

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -249,29 +249,6 @@ export function spread_props(...props) {
249249
return new Proxy({ props }, spread_props_handler);
250250
}
251251

252-
/**
253-
* @template T
254-
* @param {() => T} fn
255-
* @returns {T}
256-
*/
257-
function with_parent_tracking_context(fn) {
258-
var effect = active_effect;
259-
var previous_effect = active_effect;
260-
var previous_reaction = active_reaction;
261-
262-
while (effect !== null && (effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
263-
effect = effect.parent;
264-
}
265-
try {
266-
set_active_effect(effect);
267-
set_active_reaction(effect);
268-
return fn();
269-
} finally {
270-
set_active_effect(previous_effect);
271-
set_active_reaction(previous_reaction);
272-
}
273-
}
274-
275252
/**
276253
* This function is responsible for synchronizing a possibly bound prop with the inner component state.
277254
* It is used whenever the compiler sees that the component writes to the prop, or when it has a default prop_value.
@@ -290,13 +267,11 @@ export function prop(props, key, flags, fallback) {
290267
var is_store_sub = false;
291268
var prop_value;
292269

293-
with_parent_tracking_context(() => {
294-
if (bindable) {
295-
[prop_value, is_store_sub] = capture_store_binding(() => /** @type {V} */ (props[key]));
296-
} else {
297-
prop_value = /** @type {V} */ (props[key]);
298-
}
299-
});
270+
if (bindable) {
271+
[prop_value, is_store_sub] = capture_store_binding(() => /** @type {V} */ (props[key]));
272+
} else {
273+
prop_value = /** @type {V} */ (props[key]);
274+
}
300275

301276
// Can be the case when someone does `mount(Component, props)` with `let props = $state({...})`
302277
// or `createClassComponent(Component, props)`
@@ -331,7 +306,7 @@ export function prop(props, key, flags, fallback) {
331306
e.props_invalid_value(key);
332307
}
333308

334-
prop_value = with_parent_tracking_context(get_fallback);
309+
prop_value = get_fallback();
335310
if (setter) setter(prop_value);
336311
}
337312

packages/svelte/src/internal/client/runtime.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export function check_dirtiness(reaction) {
185185
// then we need to re-connect the reaction to the dependency
186186
if (is_disconnected || is_unowned_connected) {
187187
var derived = /** @type {Derived} */ (reaction);
188+
var parent = derived.parent;
188189

189190
for (i = 0; i < length; i++) {
190191
dependency = dependencies[i];
@@ -200,16 +201,10 @@ export function check_dirtiness(reaction) {
200201
if (is_disconnected) {
201202
derived.f ^= DISCONNECTED;
202203
}
203-
var parent = derived.parent;
204-
// If the unowned derived is now fully connected to the graph again (it has reactions, has a parent and
205-
// the parent is not unowned), then we can mark it as connected again, removing the need for the unowned
204+
// If the unowned derived is now fully connected to the graph again (it unowned and reconnected, has a parent
205+
// and the parent is not unowned), then we can mark it as connected again, removing the need for the unowned
206206
// flag
207-
if (
208-
is_unowned_connected &&
209-
derived.reactions !== null &&
210-
parent !== null &&
211-
(parent.f & UNOWNED) === 0
212-
) {
207+
if (is_unowned_connected && parent !== null && (parent.f & UNOWNED) === 0) {
213208
derived.f ^= UNOWNED;
214209
}
215210
}

0 commit comments

Comments
 (0)