mirror of https://github.com/sveltejs/svelte
allow event handlers to call event methods e.g. stopPropagation – closes #162
parent
941de39523
commit
8529e28c11
@ -0,0 +1,15 @@
|
||||
export default {
|
||||
solo: true,
|
||||
show: true,
|
||||
|
||||
test ( assert, component, target, window ) {
|
||||
const allow = target.querySelector( '.allow-propagation' );
|
||||
const stop = target.querySelector( '.stop-propagation' );
|
||||
|
||||
allow.dispatchEvent( new window.MouseEvent( 'click', { bubbles: true }) );
|
||||
stop.dispatchEvent( new window.MouseEvent( 'click', { bubbles: true }) );
|
||||
|
||||
assert.equal( component.get( 'foo' ), true );
|
||||
assert.equal( component.get( 'bar' ), false );
|
||||
}
|
||||
};
|
@ -0,0 +1,18 @@
|
||||
<div on:click='set({ foo: true })'>
|
||||
<button class='allow-propagation'>click me</button>
|
||||
</div>
|
||||
|
||||
<div on:click='set({ bar: true })'>
|
||||
<button class='stop-propagation' on:click='event.stopPropagation()'>click me</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
foo: false,
|
||||
bar: false
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in new issue