Skip to content

Commit 642105f

Browse files
committed
Make it work with out transitions
1 parent d546f19 commit 642105f

File tree

1 file changed

+20
-5
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+20
-5
lines changed

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import {
1010
import { get_descriptor, is_function } from '../../shared/utils.js';
1111
import { mutable_source, set, source, update } from './sources.js';
1212
import { derived, derived_safe_equal } from './deriveds.js';
13-
import { get, captured_signals, untrack } from '../runtime.js';
13+
import { get, captured_signals, untrack, active_effect } from '../runtime.js';
1414
import { safe_equals } from './equality.js';
1515
import * as e from '../errors.js';
1616
import { LEGACY_DERIVED_PROP, LEGACY_PROPS, STATE_SYMBOL } from '#client/constants';
1717
import { proxy } from '../proxy.js';
1818
import { capture_store_binding } from './store.js';
1919
import { legacy_mode_flag } from '../../flags/index.js';
20-
import { teardown } from './effects.js';
20+
import { component_context } from '../context.js';
2121

2222
/**
2323
* @param {((value?: number) => number)} fn
@@ -240,8 +240,23 @@ const spread_props_handler = {
240240
* @returns {any}
241241
*/
242242
export function props(...props) {
243-
let destroyed = false;
244-
teardown(() => (destroyed = true));
243+
let paused = false;
244+
const context = component_context;
245+
if (active_effect) {
246+
(active_effect.transitions ??= []).push({
247+
is_global: true,
248+
in() {
249+
paused = false;
250+
},
251+
out(callback) {
252+
paused = true;
253+
callback?.();
254+
},
255+
stop() {
256+
paused = true;
257+
}
258+
});
259+
}
245260
return new Proxy(
246261
{
247262
props,
@@ -254,7 +269,7 @@ export function props(...props) {
254269
return oldProps;
255270
}),
256271
get destroyed() {
257-
return destroyed;
272+
return (context?.d ?? false) || paused;
258273
}
259274
},
260275
spread_props_handler

0 commit comments

Comments
 (0)