From e50cbd4892e30364173e781dd2429e699e3e9488 Mon Sep 17 00:00:00 2001 From: Alex Kanunnikov Date: Sat, 29 Jun 2024 19:24:15 +0300 Subject: [PATCH] poc for top-level instance stabillity --- .../glimmer/lib/templates/outlet-helper-component.gts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/@ember/-internals/glimmer/lib/templates/outlet-helper-component.gts b/packages/@ember/-internals/glimmer/lib/templates/outlet-helper-component.gts index 6142600faad..70bad9c775f 100644 --- a/packages/@ember/-internals/glimmer/lib/templates/outlet-helper-component.gts +++ b/packages/@ember/-internals/glimmer/lib/templates/outlet-helper-component.gts @@ -36,10 +36,15 @@ export default class OutletHelper extends Component { return render.model; } } - const tplComponentInstance = new tpl(args); + if (tpl.instance) { + return tpl.instance.template; + } render.controller['args'] = args; + const tplComponentInstance = new tpl(args); + tplComponentInstance.template = tplComponentInstance.template.bind(render.controller); // we need to provide stable refs here to avoid re-renders - return tplComponentInstance.template.bind(render.controller); + tpl.instance = tplComponentInstance; + return tplComponentInstance.template; } get model() { const state = this.state;