MCPcopy
hub / github.com/sveltejs/svelte / validate_binding

Function validate_binding

packages/svelte/src/internal/client/validate.js:17–54  ·  view source on GitHub ↗
(binding, blockers, get_object, get_property, line, column)

Source from the content-addressed store, hash-verified

15 * @param {number} column
16 */
17export function validate_binding(binding, blockers, get_object, get_property, line, column) {
18 run_after_blockers(blockers, () => {
19 var warned = false;
20
21 var filename = dev_current_component_function?.[FILENAME];
22
23 render_effect(() => {
24 if (warned) return;
25
26 var [object, is_store_sub] = capture_store_binding(get_object);
27
28 if (is_store_sub) return;
29
30 var property = get_property();
31
32 var ran = false;
33
34 // by making the (possibly false, but it would be an extreme edge case) assumption
35 // that a getter has a corresponding setter, we can determine if a property is
36 // reactive by seeing if this effect has dependencies
37 var effect = render_effect(() => {
38 if (ran) return;
39
40 // eslint-disable-next-line @typescript-eslint/no-unused-expressions
41 object[property];
42 });
43
44 ran = true;
45
46 if (effect.deps === null) {
47 var location = `${filename}:${line}:${column}`;
48 w.binding_property_non_reactive(binding, location);
49
50 warned = true;
51 }
52 });
53 });
54}

Callers

nothing calls this directly

Calls 3

run_after_blockersFunction · 0.90
render_effectFunction · 0.90
capture_store_bindingFunction · 0.90

Tested by

no test coverage detected