mirror of https://github.com/sveltejs/svelte
				
				
				
			event propagation shorthand for components (#638)
	
		
	
				
					
				
			
							parent
							
								
									51af8c29e0
								
							
						
					
					
						commit
						1b92f5fa20
					
				@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					<button on:click='fire("foo", { answer: 42 })'>click me</button>
 | 
				
			||||||
@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					export default {
 | 
				
			||||||
 | 
						html: `
 | 
				
			||||||
 | 
							<button>click me</button>
 | 
				
			||||||
 | 
						`,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						test (assert, component, target, window) {
 | 
				
			||||||
 | 
							const button = target.querySelector('button');
 | 
				
			||||||
 | 
							const event = new window.MouseEvent('click');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							let answer;
 | 
				
			||||||
 | 
							component.on('foo', event => {
 | 
				
			||||||
 | 
								answer = event.answer;
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							button.dispatchEvent(event);
 | 
				
			||||||
 | 
							assert.equal(answer, 42);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					<Widget on:foo/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
						import Widget from './Widget.html';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						export default {
 | 
				
			||||||
 | 
							components: {
 | 
				
			||||||
 | 
								Widget
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue