Skip to content

Commit 8b9b6a9

Browse files
committed
no need for two vars, one will do
1 parent 7995996 commit 8b9b6a9

File tree

1 file changed

+13
-13
lines changed
  • packages/svelte/src/compiler/phases/3-transform/client/visitors/shared

1 file changed

+13
-13
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/utils.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ export function validate_binding(state, binding, expression) {
303303
* @param {Expression} expression
304304
*/
305305
export function validate_mutation(node, context, expression) {
306-
const left = node.type === 'AssignmentExpression' ? node.left : node.argument;
306+
let left = /** @type {Expression | Super} */ (
307+
node.type === 'AssignmentExpression' ? node.left : node.argument
308+
);
307309

308310
if (!dev || left.type !== 'MemberExpression' || is_ignored(node, 'ownership_invalid_mutation')) {
309311
return expression;
@@ -316,27 +318,25 @@ export function validate_mutation(node, context, expression) {
316318
if (binding?.kind !== 'prop' && binding?.kind !== 'bindable_prop') return expression;
317319

318320
const state = /** @type {ComponentClientTransformState} */ (context.state);
319-
320321
state.analysis.needs_mutation_validation = true;
321322

322323
/** @type {Array<Identifier | Literal>} */
323324
const path = [];
324-
/** @type {Expression | Super} */
325-
let current = left;
326-
327-
while (current.type === 'MemberExpression') {
328-
if (current.property.type === 'Literal') {
329-
path.unshift(current.property);
330-
} else if (current.property.type === 'Identifier') {
331-
if (current.computed) {
332-
path.unshift(current.property);
325+
326+
while (left.type === 'MemberExpression') {
327+
if (left.property.type === 'Literal') {
328+
path.unshift(left.property);
329+
} else if (left.property.type === 'Identifier') {
330+
if (left.computed) {
331+
path.unshift(left.property);
333332
} else {
334-
path.unshift(b.literal(current.property.name));
333+
path.unshift(b.literal(left.property.name));
335334
}
336335
} else {
337336
return expression;
338337
}
339-
current = current.object;
338+
339+
left = left.object;
340340
}
341341

342342
path.unshift(b.literal(name.name));

0 commit comments

Comments
 (0)