fix: use `transform.read` for `ownership_validator.mutation` array (#15848)

pull/15904/head
Paolo Ricciuti 4 months ago committed by GitHub
parent 77bdf249ff
commit 2bc2ae0ddd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: use `transform.read` for `ownership_validator.mutation` array

@ -324,15 +324,18 @@ export function validate_mutation(node, context, expression) {
const state = /** @type {ComponentClientTransformState} */ (context.state); const state = /** @type {ComponentClientTransformState} */ (context.state);
state.analysis.needs_mutation_validation = true; state.analysis.needs_mutation_validation = true;
/** @type {Array<Identifier | Literal>} */ /** @type {Array<Identifier | Literal | Expression>} */
const path = []; const path = [];
while (left.type === 'MemberExpression') { while (left.type === 'MemberExpression') {
if (left.property.type === 'Literal') { if (left.property.type === 'Literal') {
path.unshift(left.property); path.unshift(left.property);
} else if (left.property.type === 'Identifier') { } else if (left.property.type === 'Identifier') {
const transform = Object.hasOwn(context.state.transform, left.property.name)
? context.state.transform[left.property.name]
: null;
if (left.computed) { if (left.computed) {
path.unshift(left.property); path.unshift(transform?.read ? transform.read(left.property) : left.property);
} else { } else {
path.unshift(b.literal(left.property.name)); path.unshift(b.literal(left.property.name));
} }

@ -0,0 +1,10 @@
import { test } from '../../test';
export default test({
compileOptions: {
dev: true
},
async test({ assert, errors }) {
assert.deepEqual(errors, []);
}
});

@ -0,0 +1,5 @@
<script lang="ts">
let { rows = $bindable([]), row } = $props();
rows[row] = '';
</script>
Loading…
Cancel
Save