|
|
@ -2493,6 +2493,12 @@ export const template_visitors = {
|
|
|
|
getters: { ...context.state.getters }
|
|
|
|
getters: { ...context.state.getters }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The state used when generating the key function, if necessary */
|
|
|
|
|
|
|
|
const key_state = {
|
|
|
|
|
|
|
|
...context.state,
|
|
|
|
|
|
|
|
getters: { ...context.state.getters }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {Pattern} expression_for_id
|
|
|
|
* @param {Pattern} expression_for_id
|
|
|
|
* @returns {Binding['mutation']}
|
|
|
|
* @returns {Binding['mutation']}
|
|
|
@ -2550,8 +2556,12 @@ export const template_visitors = {
|
|
|
|
if (node.index) {
|
|
|
|
if (node.index) {
|
|
|
|
child_state.getters[node.index] = (id) => {
|
|
|
|
child_state.getters[node.index] = (id) => {
|
|
|
|
const index_with_loc = with_loc(index, id);
|
|
|
|
const index_with_loc = with_loc(index, id);
|
|
|
|
return b.call('$.unwrap', index_with_loc);
|
|
|
|
return (flags & EACH_INDEX_REACTIVE) === 0
|
|
|
|
|
|
|
|
? index_with_loc
|
|
|
|
|
|
|
|
: b.call('$.get', index_with_loc);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
key_state.getters[node.index] = b.id(node.index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {Statement[]} */
|
|
|
|
/** @type {Statement[]} */
|
|
|
@ -2565,6 +2575,8 @@ export const template_visitors = {
|
|
|
|
true
|
|
|
|
true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
key_state.getters[node.context.name] = node.context;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const unwrapped = getter(binding.node);
|
|
|
|
const unwrapped = getter(binding.node);
|
|
|
|
const paths = extract_paths(node.context);
|
|
|
|
const paths = extract_paths(node.context);
|
|
|
@ -2592,23 +2604,20 @@ export const template_visitors = {
|
|
|
|
if (context.state.options.dev) {
|
|
|
|
if (context.state.options.dev) {
|
|
|
|
declarations.push(b.stmt(getter));
|
|
|
|
declarations.push(b.stmt(getter));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
key_state.getters[name] = path.node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const block = /** @type {BlockStatement} */ (context.visit(node.body, child_state));
|
|
|
|
const block = /** @type {BlockStatement} */ (context.visit(node.body, child_state));
|
|
|
|
|
|
|
|
|
|
|
|
const key_function = node.key
|
|
|
|
/** @type {Expression} */
|
|
|
|
? b.arrow(
|
|
|
|
let key_function = b.id('$.index');
|
|
|
|
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
|
|
|
|
|
|
|
|
declarations.length > 0
|
|
|
|
if (node.key) {
|
|
|
|
? b.block(
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(node.key, key_state));
|
|
|
|
declarations.concat(
|
|
|
|
key_function = b.arrow([node.context, index], expression);
|
|
|
|
b.return(/** @type {Expression} */ (context.visit(node.key, child_state)))
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: /** @type {Expression} */ (context.visit(node.key, child_state))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: b.id('$.index');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (node.index && each_node_meta.contains_group_binding) {
|
|
|
|
if (node.index && each_node_meta.contains_group_binding) {
|
|
|
|
// We needed to create a unique identifier for the index above, but we want to use the
|
|
|
|
// We needed to create a unique identifier for the index above, but we want to use the
|
|
|
|