|
|
@ -2314,12 +2314,6 @@ export const template_visitors = {
|
|
|
|
// TODO should use context.visit?
|
|
|
|
// TODO should use context.visit?
|
|
|
|
const children = create_block(node, 'each_block', node.body.nodes, context);
|
|
|
|
const children = create_block(node, 'each_block', node.body.nodes, context);
|
|
|
|
|
|
|
|
|
|
|
|
const else_block = node.fallback
|
|
|
|
|
|
|
|
? b.arrow(
|
|
|
|
|
|
|
|
[b.id('$$anchor')],
|
|
|
|
|
|
|
|
/** @type {import('estree').BlockStatement} */ (context.visit(node.fallback))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: b.literal(null);
|
|
|
|
|
|
|
|
const key_function = node.key
|
|
|
|
const key_function = node.key
|
|
|
|
? b.arrow(
|
|
|
|
? b.arrow(
|
|
|
|
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
|
|
|
|
[node.context.type === 'Identifier' ? node.context : b.id('$$item'), index],
|
|
|
@ -2337,6 +2331,11 @@ export const template_visitors = {
|
|
|
|
declarations.push(b.let(node.index, index));
|
|
|
|
declarations.push(b.let(node.index, index));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let callee = '$.each_indexed';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {import('estree').Expression[]} */
|
|
|
|
|
|
|
|
const args = [];
|
|
|
|
|
|
|
|
|
|
|
|
if ((each_type & EACH_KEYED) !== 0) {
|
|
|
|
if ((each_type & EACH_KEYED) !== 0) {
|
|
|
|
if (context.state.options.dev && key_function.type !== 'Literal') {
|
|
|
|
if (context.state.options.dev && key_function.type !== 'Literal') {
|
|
|
|
context.state.init.push(
|
|
|
|
context.state.init.push(
|
|
|
@ -2344,33 +2343,34 @@ export const template_visitors = {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
context.state.after_update.push(
|
|
|
|
callee = '$.each_keyed';
|
|
|
|
b.stmt(
|
|
|
|
|
|
|
|
b.call(
|
|
|
|
args.push(
|
|
|
|
'$.each_keyed',
|
|
|
|
|
|
|
|
context.state.node,
|
|
|
|
context.state.node,
|
|
|
|
each_node_meta.array_name ? each_node_meta.array_name : b.thunk(collection),
|
|
|
|
each_node_meta.array_name ? each_node_meta.array_name : b.thunk(collection),
|
|
|
|
b.literal(each_type),
|
|
|
|
b.literal(each_type),
|
|
|
|
key_function,
|
|
|
|
key_function,
|
|
|
|
b.arrow([b.id('$$anchor'), item, index], b.block(declarations.concat(children))),
|
|
|
|
b.arrow([b.id('$$anchor'), item, index], b.block(declarations.concat(children)))
|
|
|
|
else_block
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
context.state.after_update.push(
|
|
|
|
args.push(
|
|
|
|
b.stmt(
|
|
|
|
|
|
|
|
b.call(
|
|
|
|
|
|
|
|
'$.each_indexed',
|
|
|
|
|
|
|
|
context.state.node,
|
|
|
|
context.state.node,
|
|
|
|
each_node_meta.array_name ? each_node_meta.array_name : b.thunk(collection),
|
|
|
|
each_node_meta.array_name ? each_node_meta.array_name : b.thunk(collection),
|
|
|
|
b.literal(each_type),
|
|
|
|
b.literal(each_type),
|
|
|
|
b.arrow([b.id('$$anchor'), item, index], b.block(declarations.concat(children))),
|
|
|
|
b.arrow([b.id('$$anchor'), item, index], b.block(declarations.concat(children)))
|
|
|
|
else_block
|
|
|
|
);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (node.fallback) {
|
|
|
|
|
|
|
|
args.push(
|
|
|
|
|
|
|
|
b.arrow(
|
|
|
|
|
|
|
|
[b.id('$$anchor')],
|
|
|
|
|
|
|
|
/** @type {import('estree').BlockStatement} */ (context.visit(node.fallback))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.state.after_update.push(b.stmt(b.call(callee, ...args)));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
IfBlock(node, context) {
|
|
|
|
IfBlock(node, context) {
|
|
|
|
context.state.template.push('<!>');
|
|
|
|
context.state.template.push('<!>');
|
|
|
|