Skip to content

Commit ed6e1c0

Browse files
committed
DRY
1 parent a79d9e6 commit ed6e1c0

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ const handler = {
239239
}
240240
};
241241

242+
/** @param {any} object */
243+
export function observe(object) {
244+
const metadata = object[STATE_SYMBOL];
245+
if (metadata) get(metadata.v);
246+
}
247+
242248
if (DEV) {
243249
handler.setPrototypeOf = () => {
244250
throw new Error('Cannot set prototype of $state object');

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
get,
2828
is_signal,
2929
push_destroy_fn,
30-
set,
3130
execute_effect,
3231
UNINITIALIZED,
3332
derived,
@@ -36,13 +35,11 @@ import {
3635
flushSync,
3736
safe_not_equal,
3837
current_block,
39-
source,
4038
managed_effect,
4139
push,
4240
current_component_context,
4341
pop,
44-
unwrap,
45-
mutable_source
42+
unwrap
4643
} from './runtime.js';
4744
import {
4845
current_hydration_fragment,
@@ -57,12 +54,11 @@ import {
5754
get_descriptors,
5855
is_array,
5956
object_assign,
60-
object_entries,
6157
object_keys
6258
} from './utils.js';
6359
import { is_promise } from '../common.js';
6460
import { bind_transition, trigger_transitions } from './transitions.js';
65-
import { STATE_SYMBOL, proxy } from './proxy/proxy.js';
61+
import { observe, proxy } from './proxy/proxy.js';
6662

6763
/** @type {Set<string>} */
6864
const all_registerd_events = new Set();
@@ -2540,8 +2536,7 @@ export function rest_props(props_signal, rest) {
25402536
return derived(() => {
25412537
var props = unwrap(props_signal);
25422538

2543-
const metadata = props[STATE_SYMBOL];
2544-
if (metadata) get(metadata.v);
2539+
observe(props);
25452540

25462541
/** @type {Record<string, unknown>} */
25472542
var rest_props = {};

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { EMPTY_FUNC, run_all } from '../common.js';
44
import { get_descriptor, get_descriptors, is_array } from './utils.js';
55
import { PROPS_CALL_DEFAULT_VALUE, PROPS_IS_IMMUTABLE, PROPS_IS_RUNES } from '../../constants.js';
66
import { readonly } from './proxy/readonly.js';
7-
import { STATE_SYMBOL } from './proxy/proxy.js';
7+
import { observe } from './proxy/proxy.js';
88

99
export const SOURCE = 1;
1010
export const DERIVED = 1 << 1;
@@ -1463,8 +1463,7 @@ export function prop_source(props_obj, key, flags, default_value) {
14631463
sync_effect(() => {
14641464
const props = is_signal(props_obj) ? get(props_obj) : props_obj;
14651465

1466-
const metadata = props[STATE_SYMBOL];
1467-
if (metadata) get(metadata.v);
1466+
observe(props_obj);
14681467

14691468
// Before if to ensure signal dependency is registered
14701469
const propagating_value = props[key];

0 commit comments

Comments
 (0)