mirror of https://github.com/sveltejs/svelte
Merge pull request #170 from sveltejs/gh-162
Allow event handlers to call methods of `event` and `this`pull/173/head
commit
72dc86aa5e
@ -0,0 +1,12 @@
|
||||
export default {
|
||||
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>
|
@ -0,0 +1,2 @@
|
||||
<input class='wont-focus'>
|
||||
<input class='will-focus' on:click='this.focus()'>
|
Loading…
Reference in new issue