mirror of https://github.com/sveltejs/svelte
Add trusted modifier (#6149)
Fixes #6137 Adding a trusted modifier to make events not be dispatchable by console/sourcecode. Useful to prevent injected code to automatically dispatch event for preventing bottingpull/6461/head
parent
e43778a0c4
commit
b464320607
@ -0,0 +1,9 @@
|
|||||||
|
export default {
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
const event = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await button.dispatchEvent(event);
|
||||||
|
assert.equal(component.trusted, true);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
export let trusted = true;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click|trusted="{() => trusted = false}">Only trusted events: {trusted?'true':'false'}</button>
|
Loading…
Reference in new issue