0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00

component events

This commit is contained in:
Rich Harris 2018-04-24 09:00:42 -04:00
parent d960827f96
commit 53374daf42

View File

@ -331,6 +331,10 @@ export default class Component extends Node {
`;
}
this.handlers.forEach(handler => {
handler.render(compiler, block);
});
if (this.name === 'svelte:component') {
const switch_value = block.getUniqueName('switch_value');
const switch_props = block.getUniqueName('switch_props');
@ -359,7 +363,7 @@ export default class Component extends Node {
${this.handlers.map(handler => deindent`
function ${handler.var}(event) {
${handler.body}
${handler.snippet}
}
if (${name}) ${name}.on("${handler.name}", ${handler.var});
@ -440,7 +444,7 @@ export default class Component extends Node {
${this.handlers.map(handler => deindent`
${name}.on("${handler.name}", function(event) {
${handler.body}
${handler.snippet}
});
`)}