Skip to content

Commit 587c385

Browse files
committed
Much better implementation
1 parent 8072ab5 commit 587c385

File tree

1 file changed

+9
-18
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+9
-18
lines changed

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import { derived, derived_safe_equal } from './deriveds.js';
1313
import { get, captured_signals, untrack, active_effect } from '../runtime.js';
1414
import { safe_equals } from './equality.js';
1515
import * as e from '../errors.js';
16-
import { LEGACY_DERIVED_PROP, LEGACY_PROPS, STATE_SYMBOL } from '#client/constants';
16+
import {
17+
DESTROYED,
18+
INERT,
19+
LEGACY_DERIVED_PROP,
20+
LEGACY_PROPS,
21+
STATE_SYMBOL
22+
} from '#client/constants';
1723
import { proxy } from '../proxy.js';
1824
import { capture_store_binding } from './store.js';
1925
import { legacy_mode_flag } from '../../flags/index.js';
@@ -240,22 +246,7 @@ const spread_props_handler = {
240246
* @returns {any}
241247
*/
242248
export function props(...props) {
243-
let destroyed = false;
244-
if (active_effect) {
245-
(active_effect.transitions ??= []).push({
246-
is_global: true,
247-
in() {
248-
destroyed = false;
249-
},
250-
out(callback) {
251-
destroyed = true;
252-
callback?.();
253-
},
254-
stop() {
255-
destroyed = true;
256-
}
257-
});
258-
}
249+
const effect = active_effect;
259250
return new Proxy(
260251
{
261252
props,
@@ -268,7 +259,7 @@ export function props(...props) {
268259
return old_props;
269260
}),
270261
get destroyed() {
271-
return destroyed;
262+
return effect ? (effect.f & (DESTROYED | INERT)) !== 0 : false;
272263
}
273264
},
274265
spread_props_handler

0 commit comments

Comments
 (0)