proxied-state-each-blocks
Dominic Gannaway 9 months ago
parent c063a71729
commit 236b191b78

@ -1,5 +1,5 @@
import { effect_active, get, set, increment, source } from './runtime.js';
import { get_descriptor } from './utils.js';
import { get_descriptor, is_array } from './utils.js';
/** @typedef {{ p: StateObject | null; s: Map<string | symbol, import('./types.js').SourceSignal<any>>; v: import('./types.js').SourceSignal<number>; a: boolean }} Metadata */
/** @typedef {Record<string | symbol, any> & { [STATE_SYMBOL]: Metadata }} StateObject */
@ -54,7 +54,7 @@ function init(value, parent) {
p: parent,
s: new Map(),
v: source(0),
a: Array.isArray(value)
a: is_array(value)
};
}

@ -2104,13 +2104,14 @@ export function destroy_each_item_block(
* @returns {import('./types.js').EachItemBlock}
*/
export function each_item_block(array, item, key, index, render_fn, flags) {
const each_item_not_reactive = (flags & EACH_ITEM_REACTIVE) === 0;
const item_value =
(flags & EACH_IS_PROXIED) !== 0 && (flags & EACH_KEYED) === 0
? lazy_property(array, index)
: (flags & EACH_ITEM_REACTIVE) === 0
: each_item_not_reactive
? item
: source(item);
const index_value = (flags & EACH_INDEX_REACTIVE) === 0 ? index : source(index);
const index_value = each_item_not_reactive ? index : source(index);
const block = create_each_item_block(item_value, index_value, key);
const effect = render_effect(
/** @param {import('./types.js').EachItemBlock} block */

Loading…
Cancel
Save