Skip to content

Commit d093af0

Browse files
committed
move some code
1 parent 5c81887 commit d093af0

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

packages/svelte/src/compiler/phases/3-transform/server/visitors/AssignmentExpression.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ export function AssignmentExpression(node, context) {
1313
const parent = /** @type {Node} */ (context.path.at(-1));
1414
const is_standalone = parent.type.endsWith('Statement');
1515

16-
return serialize_assignment(node, context, is_standalone, context.next);
17-
}
18-
19-
/**
20-
* @param {AssignmentExpression} node
21-
* @param {import('zimmerframe').Context<SvelteNode, ServerTransformState>} context
22-
* @param {boolean} is_standalone
23-
* @param {() => any} fallback
24-
* @returns {Expression}
25-
*/
26-
function serialize_assignment(node, context, is_standalone, fallback) {
2716
if (
2817
node.left.type === 'ArrayPattern' ||
2918
node.left.type === 'ObjectPattern' ||
@@ -38,15 +27,15 @@ function serialize_assignment(node, context, is_standalone, fallback) {
3827
const assignments = extract_paths(node.left).map((path) => {
3928
const assignment = b.assignment('=', path.node, path.expression?.(rhs));
4029

41-
return serialize_assignment(assignment, context, false, () => {
30+
return serialize_assignment(assignment, context, () => {
4231
unchanged += 1;
4332
return assignment;
4433
});
4534
});
4635

4736
if (unchanged === assignments.length) {
4837
// No change to output -> nothing to transform -> we can keep the original assignment
49-
return fallback();
38+
return context.next();
5039
}
5140

5241
const sequence = b.sequence(assignments);
@@ -64,6 +53,16 @@ function serialize_assignment(node, context, is_standalone, fallback) {
6453
return sequence;
6554
}
6655

56+
return serialize_assignment(node, context, context.next);
57+
}
58+
59+
/**
60+
* @param {AssignmentExpression} node
61+
* @param {import('zimmerframe').Context<SvelteNode, ServerTransformState>} context
62+
* @param {() => any} fallback
63+
* @returns {Expression}
64+
*/
65+
function serialize_assignment(node, context, fallback) {
6766
let left = node.left;
6867

6968
while (left.type === 'MemberExpression') {

0 commit comments

Comments
 (0)