Skip to content

Commit

Permalink
fix: deduplicate generated props and action arg names (#10669)
Browse files Browse the repository at this point in the history
fixes #10662
  • Loading branch information
dummdidumm authored Feb 29, 2024
1 parent e21488f commit b1b51a4
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/unlucky-steaks-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: deduplicate generated props and action arg names
Original file line number Diff line number Diff line change
Expand Up @@ -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[]} */
Expand Down
Original file line number Diff line number Diff line change
@@ -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>');
}
});
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script>
export let action;
export let state;
</script>

<div use:action={state}></div>

0 comments on commit b1b51a4

Please sign in to comment.