mirror of https://github.com/sveltejs/svelte
parent
fcfbffe50b
commit
9b0a884035
@ -0,0 +1,11 @@
|
||||
export default {
|
||||
html: `<button>0</button>`,
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
const button = target.querySelector( 'button' );
|
||||
const click = new window.MouseEvent( 'click' );
|
||||
|
||||
button.dispatchEvent( click );
|
||||
assert.htmlEqual( target.innerHTML, `<button>1</button>` );
|
||||
}
|
||||
};
|
@ -0,0 +1,22 @@
|
||||
<button use:foo>{{x}}</button>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
actions: {
|
||||
foo(node) {
|
||||
let x = 0;
|
||||
|
||||
const handler = () => this.set({ x: x++ });
|
||||
|
||||
node.addEventListener('click', handler);
|
||||
handler();
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener('click', handler);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue