fix: retain fallback ColorSwatch ids on slot roots
This commit is contained in:
@@ -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<string | undefined>("child-id");
|
||||
const childRef = ref<HTMLElement | null>(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(
|
||||
|
||||
Reference in New Issue
Block a user