From 53374daf42c26ad623617a89d3ac0ec649b5efbd Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 24 Apr 2018 09:00:42 -0400 Subject: [PATCH] component events --- src/generators/nodes/Component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/generators/nodes/Component.ts b/src/generators/nodes/Component.ts index 8bc6ade9c9..30278b98de 100644 --- a/src/generators/nodes/Component.ts +++ b/src/generators/nodes/Component.ts @@ -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} }); `)}