-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: apply dynamic event fixes to OnDirective (#12582)
* fix: apply dynamic event fixes to OnDirective * build
- Loading branch information
Showing
9 changed files
with
70 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: apply dynamic event fixes to OnDirective |
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
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
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
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
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
26 changes: 26 additions & 0 deletions
26
packages/svelte/tests/runtime-runes/samples/dynamic-element-event-handler-2/_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,26 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
html: '<button>Tama</button><button>Pochi</button><br><button>Change Function</button>', | ||
|
||
test({ assert, logs, target }) { | ||
const [b1, b2, b3] = target.querySelectorAll('button'); | ||
|
||
b1?.click(); | ||
b2?.click(); | ||
b3?.click(); | ||
b1?.click(); | ||
b2?.click(); | ||
|
||
assert.deepEqual(logs, [ | ||
'creating "Hello" handler for Tama', | ||
'Hello Tama', | ||
'creating "Hello" handler for Pochi', | ||
'Hello Pochi', | ||
'creating "Bye" handler for Tama', | ||
'Bye Tama', | ||
'creating "Bye" handler for Pochi', | ||
'Bye Pochi' | ||
]); | ||
} | ||
}); |
19 changes: 19 additions & 0 deletions
19
packages/svelte/tests/runtime-runes/samples/dynamic-element-event-handler-2/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,19 @@ | ||
<script> | ||
let saySomething = $state(name => { | ||
console.log('creating "Hello" handler for ' + name); | ||
return { handler: () => console.log('Hello ' + name) }; | ||
}); | ||
function change() { | ||
saySomething = name => { | ||
console.log('creating "Bye" handler for ' + name); | ||
return { handler: () => console.log('Bye ' + name) }; | ||
} | ||
} | ||
</script> | ||
|
||
<button on:click={saySomething('Tama').handler}>Tama</button> | ||
<button on:click={saySomething('Pochi').handler}>Pochi</button> | ||
|
||
<br> | ||
<button on:click={change}>Change Function</button> |
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