Comparing version 5.0.0-next.241 to 5.0.0-next.242
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "5.0.0-next.241", | ||
"version": "5.0.0-next.242", | ||
"type": "module", | ||
@@ -8,0 +8,0 @@ "types": "./types/index.d.ts", |
@@ -150,3 +150,3 @@ /** @import { BlockStatement, Expression, Identifier, Pattern, Statement } from 'estree' */ | ||
each_node_meta.contains_group_binding || !node.index ? each_node_meta.index : b.id(node.index); | ||
const item = each_node_meta.item; | ||
const item = node.context.type === 'Identifier' ? node.context : b.id('$$item'); | ||
@@ -153,0 +153,0 @@ let uses_index = each_node_meta.contains_group_binding; |
@@ -35,3 +35,3 @@ /** @import { CallExpression, Expression, Identifier, Literal, VariableDeclaration, VariableDeclarator } from 'estree' */ | ||
context.state.hoisted.push( | ||
b.declaration('const', declarator.id, /** @type {Expression} */ (context.visit(init))) | ||
b.const(declarator.id, /** @type {Expression} */ (context.visit(init))) | ||
); | ||
@@ -209,3 +209,3 @@ | ||
context.state.hoisted.push( | ||
b.declaration('const', declarator.id, /** @type {Expression} */ (context.visit(init))) | ||
b.const(declarator.id, /** @type {Expression} */ (context.visit(init))) | ||
); | ||
@@ -212,0 +212,0 @@ |
@@ -17,3 +17,2 @@ /** @import { BlockStatement, Expression, Pattern, Statement } from 'estree' */ | ||
const collection = /** @type {Expression} */ (context.visit(node.expression)); | ||
const item = each_node_meta.item; | ||
const index = | ||
@@ -26,7 +25,4 @@ each_node_meta.contains_group_binding || !node.index ? each_node_meta.index : b.id(node.index); | ||
/** @type {Statement[]} */ | ||
const each = [b.const(item, b.member(array_id, index, true))]; | ||
const each = [b.const(/** @type {Pattern} */ (node.context), b.member(array_id, index, true))]; | ||
if (node.context.type !== 'Identifier') { | ||
each.push(b.const(/** @type {Pattern} */ (node.context), item)); | ||
} | ||
if (index.name !== node.index && node.index != null) { | ||
@@ -39,4 +35,7 @@ each.push(b.let(node.index, index)); | ||
const for_loop = b.for( | ||
b.let(index, b.literal(0)), | ||
b.binary('<', index, b.member(array_id, 'length')), | ||
b.declaration('let', [ | ||
b.declarator(index, b.literal(0)), | ||
b.declarator('$$length', b.member(array_id, 'length')) | ||
]), | ||
b.binary('<', index, b.id('$$length')), | ||
b.update('++', index, false), | ||
@@ -43,0 +42,0 @@ b.block(each) |
@@ -290,6 +290,7 @@ /** @import { Context } from 'zimmerframe' */ | ||
))), | ||
/** if a component or snippet starts with text, we need to add an anchor comment so that its text node doesn't get fused with its surroundings */ | ||
/** if a component/snippet/each block starts with text, we need to add an anchor comment so that its text node doesn't get fused with its surroundings */ | ||
is_text_first: | ||
(parent.type === 'Fragment' || | ||
parent.type === 'SnippetBlock' || | ||
parent.type === 'EachBlock' || | ||
parent.type === 'SvelteComponent' || | ||
@@ -296,0 +297,0 @@ parent.type === 'Component' || |
@@ -550,5 +550,3 @@ /** @import { ClassDeclaration, Expression, FunctionDeclaration, Identifier, ImportDeclaration, MemberExpression, Node, Pattern, VariableDeclarator } from 'estree' */ | ||
} | ||
if (node.context.type !== 'Identifier') { | ||
scope.declare(b.id('$$item'), 'template', 'synthetic'); | ||
} | ||
// Visit to pick up references from default initializers | ||
@@ -587,3 +585,2 @@ visit(node.context, { scope }); | ||
index: scope.root.unique('$$index'), | ||
item: node.context.type === 'Identifier' ? node.context : b.id('$$item'), | ||
declarations: scope.declarations, | ||
@@ -590,0 +587,0 @@ is_controlled: false |
@@ -408,3 +408,2 @@ import type { Binding, Css, ExpressionMetadata } from '#compiler'; | ||
index: Identifier; | ||
item: Identifier; | ||
declarations: Map<string, Binding>; | ||
@@ -411,0 +410,0 @@ /** |
@@ -179,13 +179,10 @@ /** @import * as ESTree from 'estree' */ | ||
* @param {'const' | 'let' | 'var'} kind | ||
* @param {string | ESTree.Pattern} pattern | ||
* @param {ESTree.Expression} [init] | ||
* @param {ESTree.VariableDeclarator[]} declarations | ||
* @returns {ESTree.VariableDeclaration} | ||
*/ | ||
export function declaration(kind, pattern, init) { | ||
if (typeof pattern === 'string') pattern = id(pattern); | ||
export function declaration(kind, declarations) { | ||
return { | ||
type: 'VariableDeclaration', | ||
kind, | ||
declarations: [init ? declarator(pattern, init) : declarator(pattern)] | ||
declarations | ||
}; | ||
@@ -195,8 +192,9 @@ } | ||
/** | ||
* @param {ESTree.Pattern} id | ||
* @param {ESTree.Pattern | string} pattern | ||
* @param {ESTree.Expression} [init] | ||
* @returns {ESTree.VariableDeclarator} | ||
*/ | ||
export function declarator(id, init) { | ||
return { type: 'VariableDeclarator', id, init }; | ||
export function declarator(pattern, init) { | ||
if (typeof pattern === 'string') pattern = id(pattern); | ||
return { type: 'VariableDeclarator', id: pattern, init }; | ||
} | ||
@@ -496,3 +494,3 @@ | ||
function let_builder(pattern, init) { | ||
return declaration('let', pattern, init); | ||
return declaration('let', [declarator(pattern, init)]); | ||
} | ||
@@ -506,3 +504,3 @@ | ||
function const_builder(pattern, init) { | ||
return declaration('const', pattern, init); | ||
return declaration('const', [declarator(pattern, init)]); | ||
} | ||
@@ -516,3 +514,3 @@ | ||
function var_builder(pattern, init) { | ||
return declaration('var', pattern, init); | ||
return declaration('var', [declarator(pattern, init)]); | ||
} | ||
@@ -519,0 +517,0 @@ |
@@ -9,3 +9,3 @@ // generated during release, do not modify | ||
*/ | ||
export const VERSION = '5.0.0-next.241'; | ||
export const VERSION = '5.0.0-next.242'; | ||
export const PUBLIC_VERSION = '5'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2208791
48903