fix: deduplicate generated props and action arg names (#10669)

fixes #10662
pull/10671/head
Simon H 4 months ago committed by GitHub
parent e21488fc4b
commit b1b51a404b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: deduplicate generated props and action arg names

@ -2668,7 +2668,7 @@ export const template_visitors = {
const params = [b.id('$$node')];
if (node.expression) {
params.push(b.id('$$props'));
params.push(b.id('$$action_arg'));
}
/** @type {import('estree').Expression[]} */

@ -0,0 +1,14 @@
import { tick } from 'svelte';
import { test } from '../../test';
export default test({
accessors: false,
async test({ assert, target }) {
assert.htmlEqual(target.innerHTML, '<button>foo / foo</button><div></div>');
const button = target.querySelector('button');
button?.click();
await tick();
assert.htmlEqual(target.innerHTML, '<button>bar / bar</button><div></div>');
}
});

@ -0,0 +1,17 @@
<script>
import Component from "./sub.svelte"
let state = 'foo';
let param = '';
function action(node, _param) {
param = _param
return {
update(_param) {
param = _param;
}
};
}
</script>
<button on:click={() => state = 'bar'}>{state} / {param}</button>
<Component {action} {state}></Component>

@ -0,0 +1,6 @@
<script>
export let action;
export let state;
</script>
<div use:action={state}></div>
Loading…
Cancel
Save