diff --git a/docs/tasks/ACTIVE.md b/docs/tasks/ACTIVE.md index d15a431..04b552f 100644 --- a/docs/tasks/ACTIVE.md +++ b/docs/tasks/ACTIVE.md @@ -1,6 +1,6 @@ # 当前工作区交接 -- 任务:无进行中任务;COLOR-SWATCH 两项复核问题已修复并交付到任务分支。 +- 任务:无进行中任务;COLOR-SWATCH 已通过集成人复核,动态移除子ID的尾部问题已补齐。 - 工作区/分支:heroui-vue / feat/color-swatch-public(起点 60af6ee,未合 main、未 push)。 - 结果入口:docs/tasks/results/COLOR-SWATCH.md(含 CS-1/CS-2 返修记录)。 - 下一步:由用户选择新任务;不自动开始下一任务。 diff --git a/docs/tasks/COLOR-SWATCH.md b/docs/tasks/COLOR-SWATCH.md index 6737526..f708200 100644 --- a/docs/tasks/COLOR-SWATCH.md +++ b/docs/tasks/COLOR-SWATCH.md @@ -2,7 +2,7 @@ { "base": "b129f79366e6a526e047cec917753e1434298fa3", "upstream": "ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960", - "status": "done", + "status": "accepted", "requires": [ "packages/vue/src/components/color/value.ts", "packages/vue/src/components/color/model.ts", diff --git a/docs/tasks/results/COLOR-SWATCH.md b/docs/tasks/results/COLOR-SWATCH.md index e1e2cca..dc1e05b 100644 --- a/docs/tasks/results/COLOR-SWATCH.md +++ b/docs/tasks/results/COLOR-SWATCH.md @@ -63,3 +63,9 @@ Color.toWire目前仍出现在公开class声明中,虽然没有泄漏Reka具 | 类型与文档构建 | `pnpm typecheck`、`pnpm build:docs` 通过 | | 独立产物 | `node scripts/check-package.mjs color-swatch` 通过;最终声明仍暴露 `element` 且无 Reka/Wire 泄漏 | | 浏览器复验 | 5185 重新打开 `/components/color-swatch`:7 个预览、尺寸/圆角/透明度/棋盘、styleFn 发光/渐变、asChild `data-custom` 均正常;无控制台错误与横向溢出 | + +## 集成人二次复核:通过(2026-10-26) + +复核b18949c,原CS-1/CS-2均通过。CS-1仍有动态移除子id的同根因遗漏:Slot的子props.id=undefined会覆盖生成id;本次直接补齐,将最终id通过公开cloneVNode同步到实际Slot根,不操作DOM或私有ref。原组合用例追加id移除及子ref保留断言,不新增另一轮测试文件。CS-1/CS-2现均关闭。 + +最终5文件/69项定向回归、vue-tsc、独立color-swatch tarball的ESM/CSS及strict NodeNext/bundler正反类型通过。未重复全库/文档构建或逐页浏览器,未增加SSR专项或启动服务。补修提交见本记录所在提交;仍在feat/color-swatch-public,未合main/push。 diff --git a/packages/vue/src/components/color-swatch/ColorSwatch.vue b/packages/vue/src/components/color-swatch/ColorSwatch.vue index b94d474..39e7a61 100644 --- a/packages/vue/src/components/color-swatch/ColorSwatch.vue +++ b/packages/vue/src/components/color-swatch/ColorSwatch.vue @@ -3,6 +3,7 @@ import { Comment, Fragment, Text, + cloneVNode, computed, getCurrentInstance, h, @@ -160,13 +161,6 @@ function roleDescription() { : "color swatch"; } -/** Reka Slot keeps a child's own ID over merged attrs; mirror that root ID. */ -function asChildRootId(children: VNodeChild) { - const root = meaningfulVNodes(children)[0]; - const id = root?.props?.id; - return id == null ? undefined : String(id); -} - function setRoot(node: unknown) { const next = node instanceof HTMLElement @@ -177,11 +171,18 @@ function setRoot(node: unknown) { /** Functional render layer so the default slot is read once per render. */ const Render = () => { - const children = slots.default?.({ color: displayColor.value }) as + let children = slots.default?.({ color: displayColor.value }) as VNodeChild | undefined; - const childId = props.asChild ? asChildRootId(children) : undefined; + const childNodes = props.asChild ? meaningfulVNodes(children) : undefined; + const childId = childNodes?.[0]?.props?.id; const effectiveId = childId ?? (attrs.id == null ? generatedId : String(attrs.id)); + // Slot gives child props precedence, including an explicit undefined ID. + // Put the resolved ID on that VNode too, preserving Vue's ref and key. + if (childNodes?.length) { + childNodes[0] = cloneVNode(childNodes[0]!, { id: effectiveId }); + children = childNodes; + } const labelledBy = attrs["aria-labelledby"]; return h( diff --git a/tests/regressions/color/swatch-composition.test.ts b/tests/regressions/color/swatch-composition.test.ts index 595338a..f84d7dc 100644 --- a/tests/regressions/color/swatch-composition.test.ts +++ b/tests/regressions/color/swatch-composition.test.ts @@ -9,7 +9,8 @@ afterEach(() => { document.body.innerHTML = ""; }); it("keeps asChild self-labelledby attached to the actual root ID", async () => { - const id = ref("child-id"); + const id = ref("child-id"); + const childRef = ref(null); const w = mount( defineComponent({ setup: () => () => @@ -19,7 +20,7 @@ it("keeps asChild self-labelledby attached to the actual root ID", async () => { ColorSwatch, { asChild: true, color: "#0485F7", "aria-labelledby": "caption" }, { - default: () => h("div", { id: id.value }), + default: () => h("div", { id: id.value, ref: childRef }), }, ), ]), @@ -36,6 +37,13 @@ it("keeps asChild self-labelledby attached to the actual root ID", async () => { expect(root.attributes("aria-labelledby")).toBe( `${root.attributes("id")} caption`, ); + id.value = undefined; + await nextTick(); + expect(root.attributes("id")).toBeTruthy(); + expect(childRef.value).toBe(root.element); + expect(root.attributes("aria-labelledby")).toBe( + `${root.attributes("id")} caption`, + ); }); it("retains ordinary template styles together with styleFn", () => { const w = mount(