From 561e49e5eb36050247775f32b7dab8835e1c9dde Mon Sep 17 00:00:00 2001 From: Ildar Kayumov Date: Sat, 25 May 2024 16:53:19 +0200 Subject: [PATCH] Do not ScopeObserver#scopeReferenceCounts when outlet is called before controller is connected --- src/core/module.ts | 7 +++++-- src/core/router.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/module.ts b/src/core/module.ts index 5635abca..624c02aa 100644 --- a/src/core/module.ts +++ b/src/core/module.ts @@ -31,8 +31,11 @@ export class Module { connectContextForScope(scope: Scope) { const context = this.fetchContextForScope(scope) - this.connectedContexts.add(context) - context.connect() + + if (!this.connectedContexts.has(context)) { + this.connectedContexts.add(context) + context.connect() + } } disconnectContextForScope(scope: Scope) { diff --git a/src/core/router.ts b/src/core/router.ts index d0d40a84..aaec6b21 100644 --- a/src/core/router.ts +++ b/src/core/router.ts @@ -79,7 +79,7 @@ export class Router implements ScopeObserverDelegate { const scope = this.scopeObserver.parseValueForElementAndIdentifier(element, identifier) if (scope) { - this.scopeObserver.elementMatchedValue(scope.element, scope) + this.scopeConnected(scope) } else { console.error(`Couldn't find or create scope for identifier: "${identifier}" and element:`, element) }