|
|
|
@ -1,23 +1,20 @@
|
|
|
|
import EachBlock from '../../../nodes/EachBlock';
|
|
|
|
/**
|
|
|
|
import InlineComponentWrapper from '../InlineComponent';
|
|
|
|
* @param {import('../Element.js').default | import('../InlineComponent.js').default} parent
|
|
|
|
import ElementWrapper from '../Element';
|
|
|
|
* @param {import('../../../nodes/Binding.js').default} binding
|
|
|
|
import Binding from '../../../nodes/Binding';
|
|
|
|
*/
|
|
|
|
|
|
|
|
export default function mark_each_block_bindings(parent, binding) {
|
|
|
|
export default function mark_each_block_bindings(
|
|
|
|
|
|
|
|
parent: ElementWrapper | InlineComponentWrapper,
|
|
|
|
|
|
|
|
binding: Binding
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
// we need to ensure that the each block creates a context including
|
|
|
|
// we need to ensure that the each block creates a context including
|
|
|
|
// the list and the index, if they're not otherwise referenced
|
|
|
|
// the list and the index, if they're not otherwise referenced
|
|
|
|
binding.expression.references.forEach((name) => {
|
|
|
|
binding.expression.references.forEach((name) => {
|
|
|
|
const each_block = parent.node.scope.get_owner(name);
|
|
|
|
const each_block = parent.node.scope.get_owner(name);
|
|
|
|
if (each_block) {
|
|
|
|
if (each_block) {
|
|
|
|
(each_block as EachBlock).has_binding = true;
|
|
|
|
( /** @type {import('../../../nodes/EachBlock.js').default} */(each_block)).has_binding = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (binding.name === 'group') {
|
|
|
|
if (binding.name === 'group') {
|
|
|
|
const add_index_binding = (name: string) => {
|
|
|
|
|
|
|
|
|
|
|
|
/** @param {string} name */
|
|
|
|
|
|
|
|
const add_index_binding = (name) => {
|
|
|
|
const each_block = parent.node.scope.get_owner(name);
|
|
|
|
const each_block = parent.node.scope.get_owner(name);
|
|
|
|
if (each_block.type === 'EachBlock') {
|
|
|
|
if (each_block.type === 'EachBlock') {
|
|
|
|
each_block.has_index_binding = true;
|
|
|
|
each_block.has_index_binding = true;
|
|
|
|
@ -32,3 +29,7 @@ export default function mark_each_block_bindings(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|