Skip to content

Commit 9f3ce12

Browse files
committed
add some JSDoc, since it could be a headscratcher for future us
1 parent 28deabd commit 9f3ce12

File tree

1 file changed

+11
-0
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { get } from '../runtime.js';
66
import { teardown } from './effects.js';
77
import { mutable_source, set } from './sources.js';
88

9+
/**
10+
* Whether or not the prop currently being read is a store binding, as in
11+
* `<Child bind:x={$y} />`. If it is, we treat the prop as mutable even in
12+
* runes mode, and skip `binding_property_non_reactive` validation
13+
*/
914
let marked_store_sub = false;
1015

1116
/**
@@ -149,11 +154,17 @@ export function update_pre_store(store, store_value, d = 1) {
149154
return value;
150155
}
151156

157+
/**
158+
* Called inside prop getters to communicate that the prop is a store binding
159+
*/
152160
export function mark_store_sub() {
153161
marked_store_sub = true;
154162
}
155163

156164
/**
165+
* Returns a tuple that indicates whether `fn()` reads a prop that is a store binding.
166+
* Used to prevent `binding_property_non_reactive` validation false positives and
167+
* ensure that these props are treated as mutable even in runes mode
157168
* @template T
158169
* @param {() => T} fn
159170
* @returns {[T, boolean]}

0 commit comments

Comments
 (0)