mirror of https://github.com/sveltejs/svelte
fix: improve import event handler support (#10592)
* fix: improve import event handler support * simplifypull/10589/head
parent
66b624491e
commit
a2fbef2050
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: improve import event handler support
|
@ -0,0 +1,20 @@
|
||||
import { test } from '../../test';
|
||||
import { log, handler, log_a } from './event.js';
|
||||
|
||||
export default test({
|
||||
before_test() {
|
||||
log.length = 0;
|
||||
handler.value = log_a;
|
||||
},
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [b1, b2] = target.querySelectorAll('button');
|
||||
|
||||
b1?.click();
|
||||
assert.deepEqual(log, ['a']);
|
||||
|
||||
b2?.click();
|
||||
b1?.click();
|
||||
assert.deepEqual(log, ['a', 'b']);
|
||||
}
|
||||
});
|
@ -0,0 +1,14 @@
|
||||
/** @type {any[]} */
|
||||
export const log = [];
|
||||
|
||||
export const log_a = () => {
|
||||
log.push('a');
|
||||
};
|
||||
|
||||
export const log_b = () => {
|
||||
log.push('b');
|
||||
};
|
||||
|
||||
export const handler = {
|
||||
value: log_a
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
<script>
|
||||
import {handler, log_b} from './event.js';
|
||||
</script>
|
||||
|
||||
<button onclick={handler.value}>click</button>
|
||||
<button onclick={() => handler.value = log_b}>change</button>
|
Loading…
Reference in new issue