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'](); } }; }