Content-Length: 380454 | pFad | http://github.com/changsik/svelte/commit/b1b51a404b1357558e963716c6182ecaccd24f20

5E fix: deduplicate generated props and action arg names (#10669) · changsik/svelte@b1b51a4 · GitHub
Skip to content

Commit b1b51a4

Browse files
authored
fix: deduplicate generated props and action arg names (sveltejs#10669)
fixes sveltejs#10662
1 parent e21488f commit b1b51a4

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

.changeset/unlucky-steaks-warn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: deduplicate generated props and action arg names

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,7 @@ export const template_visitors = {
26682668
const params = [b.id('$$node')];
26692669

26702670
if (node.expression) {
2671-
params.push(b.id('$$props'));
2671+
params.push(b.id('$$action_arg'));
26722672
}
26732673

26742674
/** @type {import('estree').Expression[]} */
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { tick } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
accessors: false,
6+
async test({ assert, target }) {
7+
assert.htmlEqual(target.innerHTML, '<button>foo / foo</button><div></div>');
8+
9+
const button = target.querySelector('button');
10+
button?.click();
11+
await tick();
12+
assert.htmlEqual(target.innerHTML, '<button>bar / bar</button><div></div>');
13+
}
14+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
import Component from "./sub.svelte"
3+
let state = 'foo';
4+
let param = '';
5+
6+
function action(node, _param) {
7+
param = _param
8+
return {
9+
update(_param) {
10+
param = _param;
11+
}
12+
};
13+
}
14+
</script>
15+
16+
<button on:click={() => state = 'bar'}>{state} / {param}</button>
17+
<Component {action} {state}></Component>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script>
2+
export let action;
3+
export let state;
4+
</script>
5+
6+
<div use:action={state}></div>

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/changsik/svelte/commit/b1b51a404b1357558e963716c6182ecaccd24f20

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy