Skip to content

Commit 2bc2ae0

Browse files
fix: use transform.read for ownership_validator.mutation array (#15848)
1 parent 77bdf24 commit 2bc2ae0

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: use `transform.read` for `ownership_validator.mutation` array

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,18 @@ export function validate_mutation(node, context, expression) {
324324
const state = /** @type {ComponentClientTransformState} */ (context.state);
325325
state.analysis.needs_mutation_validation = true;
326326

327-
/** @type {Array<Identifier | Literal>} */
327+
/** @type {Array<Identifier | Literal | Expression>} */
328328
const path = [];
329329

330330
while (left.type === 'MemberExpression') {
331331
if (left.property.type === 'Literal') {
332332
path.unshift(left.property);
333333
} else if (left.property.type === 'Identifier') {
334+
const transform = Object.hasOwn(context.state.transform, left.property.name)
335+
? context.state.transform[left.property.name]
336+
: null;
334337
if (left.computed) {
335-
path.unshift(left.property);
338+
path.unshift(transform?.read ? transform.read(left.property) : left.property);
336339
} else {
337340
path.unshift(b.literal(left.property.name));
338341
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
compileOptions: {
5+
dev: true
6+
},
7+
async test({ assert, errors }) {
8+
assert.deepEqual(errors, []);
9+
}
10+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script lang="ts">
2+
let { rows = $bindable([]), row } = $props();
3+
rows[row] = '';
4+
</script>
5+

0 commit comments

Comments
 (0)