Skip to content

Commit 79f9962

Browse files
committed
hoist
1 parent 4facc70 commit 79f9962

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

packages/svelte/src/internal/client/dev/ownership.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,24 +113,14 @@ export function create_ownership_validator(props) {
113113
const component = component_context?.function;
114114
const parent = component_context?.p?.function;
115115

116-
/** @param {string} prop_name */
117-
function is_bound(prop_name) {
118-
// Can be the case when someone does `mount(Component, props)` with `let props = $state({...})`
119-
// or `createClassComponent(Component, props)`
120-
const is_entry_props = STATE_SYMBOL in props || LEGACY_PROPS in props;
121-
const is_bound =
122-
!!get_descriptor(props, prop_name)?.set || (is_entry_props && prop_name in props);
123-
return is_bound;
124-
}
125-
126116
return {
127117
/**
128118
* @param {any[]} path
129119
* @param {any} result
130120
*/
131121
mutation: (path, result) => {
132122
const prop_name = path[0];
133-
if (is_bound(prop_name) || !parent) {
123+
if (is_bound(props, prop_name) || !parent) {
134124
return result;
135125
}
136126

@@ -153,7 +143,7 @@ export function create_ownership_validator(props) {
153143
* @param {() => any} value
154144
*/
155145
binding: (key, child_component, value) => {
156-
if (!is_bound(key) && parent && value()?.[STATE_SYMBOL]) {
146+
if (!is_bound(props, key) && parent && value()?.[STATE_SYMBOL]) {
157147
w.ownership_invalid_binding(
158148
component[FILENAME],
159149
key,
@@ -164,3 +154,14 @@ export function create_ownership_validator(props) {
164154
}
165155
};
166156
}
157+
158+
/**
159+
* @param {Record<string, any>} props
160+
* @param {string} prop_name
161+
*/
162+
function is_bound(props, prop_name) {
163+
// Can be the case when someone does `mount(Component, props)` with `let props = $state({...})`
164+
// or `createClassComponent(Component, props)`
165+
const is_entry_props = STATE_SYMBOL in props || LEGACY_PROPS in props;
166+
return !!get_descriptor(props, prop_name)?.set || (is_entry_props && prop_name in props);
167+
}

0 commit comments

Comments
 (0)