Implementation: How should PlatformRouter auto-discover dynamically inserted...

Documentation for Sessions

⚙️ Implementation: How should PlatformRouter auto-discover dynamically inserted...

Date: 2026-03-25
Time: 21:47:42 UTC
Session: gspace1-270.5
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

How should PlatformRouter auto-discover dynamically inserted routes?

Task: S270 Platform Elements Evolution


🎯 Decision Made

Chosen:

Filtered MutationObserver on the router element, installed AFTER initial setup (after discoverRoutes() and navContainer prepend). Filter only fires on PLATFORM-ROUTE node additions/removals, ignoring the router's own nav container prepend.

Options Considered:

  1. Public refreshRoutes() method called manually after insertion
  2. MutationObserver without filter (fires on own nav prepend — wasteful)
  3. Filtered MutationObserver for PLATFORM-ROUTE only (chosen)

💭 Reasoning

Verified gap: PlatformRouter did a single discoverRoutes() in connectedCallback (line 34) with no re-scan mechanism. The filter is critical — without it, the observer fires on the router's own this.prepend(this.navContainer) at line 40, causing a redundant discoverRoutes() during init. The filter checks n instanceof HTMLElement && n.tagName === 'PLATFORM-ROUTE' on added/removed nodes. This follows the same MutationObserver pattern ExpressionBindingManager already uses (lines 81-91). Benefits both production and editor — any dynamic route insertion auto-works.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation