The previous oneditprepare ran applyMode(initialMode) early in the function, which called validateChannelsJson(), which referenced const declarations (channelsArea, channelsHint) that were declared later in the same function. JavaScript hoists const into the Temporal Dead Zone, so accessing them before the declaration line throws a ReferenceError. That uncaught throw aborted the rest of oneditprepare — including the waitForMenuData() call that initialises the asset / logger / position menu placeholders. Symptom for the user: opening a measurement node in the editor showed Mode + analog fields but the asset menu was empty. Fixes: 1. Move waitForMenuData() to the very top of oneditprepare so the shared menu init is independent of any later mode-block work. Even if the mode logic ever throws again, the asset / logger / position menus still render. 2. Resolve every DOM reference (modeSelect, analogBlock, digitalBlock, modeHint, channelsArea, channelsHint) at the top of the function before any helper that touches them is invoked. validateChannelsJson and applyMode now read closed-over names that are guaranteed to be initialised. 3. Guard applyMode(initialMode) with try/catch as defense in depth and add null-checks on every DOM reference. A future template change that drops one of the IDs will only no-op rather than break the editor. No runtime change. 71/71 tests still green. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
19 KiB
19 KiB