fix(form-compile): companion наследовал DisplayImportance владельца (PowerShell dynamic scope)

Emit-Companion / Emit-CompanionPanel вызывали DI-Attr $el, но $el НЕ их параметр —
PowerShell брал его из родительского скоупа (эмитируемого элемента). Поэтому
авто-генерируемые companion (ExtendedTooltip/ContextMenu/AutoCommandBar с name="@")
наследовали DisplayImportance владельца (CheckBoxField/UsualGroup/Table), которого
в оригинале у них нет → ложный ADDED. Корпус: ExtendedTooltip/ContextMenu НИКОГДА не
несут DisplayImportance, AutoCommandBar — только element-level (11), не companion.

Фикс: DI-Attr от СОБСТВЕННОГО объекта компаньона ($content / $panel), не от ambient
$el. Python не имел dynamic-scope-бага (di_attr на companion не эмитил вовсе), но для
паритета добавлен di_attr(content/panel) — оба рантайма теперь идентичны (companion
без собственного DI → пусто).

Выборка 19 форм (СостоянияОригиналовПервичныхДокументов acc+erp, + формы с
DisplayImportance-владельцами): match 18, ADDED DisplayImportance исчез. ps1==py
байт-в-байт. Регресс 43/43.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-06-13 15:04:33 +03:00
co-authored by Claude Opus 4.8
parent e1fb40189c
commit 90d2649a5f
2 changed files with 9 additions and 6 deletions
@@ -1,4 +1,4 @@
# form-compile v1.159 — Compile 1C managed form from JSON or object metadata
# form-compile v1.160 — Compile 1C managed form from JSON or object metadata
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[string]$JsonPath,
@@ -2606,7 +2606,9 @@ function Emit-Companion {
return
}
$inner = "$indent`t"
X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
# DI-Attr берём от СОБСТВЕННОГО объекта компаньона ($content), НЕ от ambient $el родителя
# (PowerShell dynamic scope — иначе companion наследует DisplayImportance владельца: баг).
X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $content)>"
if (Test-CompanionStructured $content) {
# структурированная форма (own-content). Порядок как у платформы: own-content (флаги/hyperlink/
# layout/оформление) ПЕРЕД Title (в корпусе layout-first 582 vs 10).
@@ -2649,7 +2651,7 @@ function Emit-CompanionPanel {
X "$indent<$tag name=`"$name`" id=`"$id`"/>"
return
}
X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $el)>"
X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $panel)>"
if ($halign) { X "$indent`t<HorizontalAlign>$halign</HorizontalAlign>" }
if ($emitAfFalse) { X "$indent`t<Autofill>false</Autofill>" }
if ($hasChildren) {