From bf71af4c2f1a4b731adf16192371ec0c8c756873 Mon Sep 17 00:00:00 2001 From: ekhaled Date: Fri, 30 Mar 2018 19:57:45 +0100 Subject: [PATCH] support both destroy and teardown in custom event handlers --- src/generators/nodes/Element.ts | 2 +- test/js/samples/event-handlers-custom/expected-bundle.js | 2 +- test/js/samples/event-handlers-custom/expected.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generators/nodes/Element.ts b/src/generators/nodes/Element.ts index 288a508758..1d4f9fdf53 100644 --- a/src/generators/nodes/Element.ts +++ b/src/generators/nodes/Element.ts @@ -517,7 +517,7 @@ export default class Element extends Node { `); block.builders.destroy.addLine(deindent` - ${handlerName}.teardown(); + ${handlerName}[${handlerName}.destroy ? 'destroy' : 'teardown'](); `); } else { const handler = deindent` diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 6d0dcd3bc8..7c17164c74 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -212,7 +212,7 @@ function create_main_fragment(component, state) { }, d: function destroy$$1() { - foo_handler.teardown(); + foo_handler[foo_handler.destroy ? 'destroy' : 'teardown'](); } }; } diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index ee1d155e9d..08f964c346 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -39,7 +39,7 @@ function create_main_fragment(component, state) { }, d: function destroy() { - foo_handler.teardown(); + foo_handler[foo_handler.destroy ? 'destroy' : 'teardown'](); } }; }