Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] handle arrow function on slot inside svelte:fragment (#7667)
Fixes #7485
- Loading branch information
1 parent
9ad416b
commit 5dd703f
Showing
5 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/runtime/samples/component-slot-let-inline-function/Inner.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<script> | ||
export let log; | ||
export let b; | ||
function innerCall(a) { | ||
log(`a: ${a}, b: ${b}`); | ||
} | ||
</script> | ||
<slot name="inner_slot" {innerCall} /> |
12 changes: 12 additions & 0 deletions
12
test/runtime/samples/component-slot-let-inline-function/Outer.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
import Inner from './Inner.svelte' | ||
export let log; | ||
export let a; | ||
export let b; | ||
</script> | ||
|
||
<Inner {log} {b}> | ||
<svelte:fragment let:innerCall slot="inner_slot"> | ||
<slot outerCall={() => innerCall(a)} /> | ||
</svelte:fragment> | ||
</Inner> |
27 changes: 27 additions & 0 deletions
27
test/runtime/samples/component-slot-let-inline-function/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
let logs; | ||
function log(value) { | ||
logs.push(value); | ||
} | ||
|
||
export default { | ||
html: '<button>click me</button>', | ||
props: { | ||
a: 'a', | ||
b: 'b', | ||
log | ||
}, | ||
before_test() { | ||
logs = []; | ||
}, | ||
async test({ assert, component, target, window }) { | ||
const button = target.querySelector('button'); | ||
await button.dispatchEvent(new window.MouseEvent('click')); | ||
|
||
assert.deepEqual(logs, ['a: a, b: b']); | ||
|
||
component.a = '1'; | ||
component.b = '2'; | ||
await button.dispatchEvent(new window.MouseEvent('click')); | ||
assert.deepEqual(logs, ['a: a, b: b', 'a: 1, b: 2']); | ||
} | ||
}; |
12 changes: 12 additions & 0 deletions
12
test/runtime/samples/component-slot-let-inline-function/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
import Outer from "./Outer.svelte"; | ||
export let log = []; | ||
export let a; | ||
export let b; | ||
</script> | ||
|
||
<Outer let:outerCall {log} {a} {b}> | ||
<button on:click={outerCall}> | ||
click me | ||
</button> | ||
</Outer> |