diff --git a/.changeset/nine-yaks-grow.md b/.changeset/nine-yaks-grow.md new file mode 100644 index 0000000000..68de831637 --- /dev/null +++ b/.changeset/nine-yaks-grow.md @@ -0,0 +1,7 @@ +--- +"@siteimprove/alfa-aria": patch +--- + +**Fixed:** Name from content now correctly includes shadow DOM. + +When the accessible name is computed from the descendants, slots and descendants inside a shadow DOM are correctly taken into account. This mimic what browsers are doing, and what the accessible name conputation group seems to be moving toward. diff --git a/packages/alfa-aria/src/name.ts b/packages/alfa-aria/src/name.ts index 41a364c50c..125d40f262 100644 --- a/packages/alfa-aria/src/name.ts +++ b/packages/alfa-aria/src/name.ts @@ -198,7 +198,7 @@ export namespace Name { public toJSON(): Descendant.JSON { return { type: "descendant", - element: this._element.path(), + element: this._element.path(Node.flatTree), name: this._name.toJSON(), }; } @@ -823,7 +823,7 @@ export namespace Name { state: State ): Option { const names: Sequence = element - .children() + .children(Node.flatTree) .filter(or(isText, isElement)) .collect((element) => fromNode(element, device, state.recurse(true).descend(true)).map( diff --git a/packages/alfa-aria/test/name.spec.tsx b/packages/alfa-aria/test/name.spec.tsx index 7052ee7cc0..9c396fa873 100644 --- a/packages/alfa-aria/test/name.spec.tsx +++ b/packages/alfa-aria/test/name.spec.tsx @@ -1659,3 +1659,90 @@ test(`.from() only associates