mirror of https://github.com/sveltejs/svelte
feat: add stopImmediatePropagation event modifier (#8341)
Closes #5085 --------- Co-authored-by: Marcin Wicha <23581770+marcin-wicha@users.noreply.github.com> Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>pull/8342/head
parent
acbf8135a8
commit
c611f318d2
@ -0,0 +1,17 @@
|
|||||||
|
export default {
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const event = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.deepEqual(component.logs, ['click_1', 'click_2']);
|
||||||
|
|
||||||
|
component.click_2 = () => component.logs.push('22');
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.deepEqual(component.logs, ['click_1', 'click_2', 'click_1', '22']);
|
||||||
|
|
||||||
|
component.click_1 = () => component.logs.push('11');
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.deepEqual(component.logs, ['click_1', 'click_2', 'click_1', '22', '11', '22']);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,22 @@
|
|||||||
|
<script>
|
||||||
|
export let logs = [];
|
||||||
|
|
||||||
|
export let click_1 = () => {
|
||||||
|
logs.push('click_1');
|
||||||
|
}
|
||||||
|
|
||||||
|
export let click_2 = () => {
|
||||||
|
logs.push('click_2');
|
||||||
|
}
|
||||||
|
|
||||||
|
export let click_3 = () => {
|
||||||
|
logs.push('click_3');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button
|
||||||
|
on:click={click_1}
|
||||||
|
on:click|stopImmediatePropagation={click_2}
|
||||||
|
on:click={click_3}>
|
||||||
|
click me
|
||||||
|
</button>
|
Loading…
Reference in new issue