fix(runtime): pass child sibling index to nested <Transform> (Ink parity, G21) (#50)
* fix(runtime): pass child sibling index to nested <Transform> (Ink parity, G21) paint.ts renderTextWithInlineStyles and text-measure.ts flattenLeaves squash loops now pass the child's position index to child.transform instead of a hardcoded 0, matching Ink squash-text-nodes.ts:13,38 where internal_transform receives the plain loop counter over node.childNodes (all siblings). A nested <Transform> that is the Nth child of a <Text> therefore gets index = N. Both spots use the same index basis so paint and measurement agree. Refines the earlier G06 refutation — the inline/squash path was the real gap. Also adds the `innerText.length > 0` guard in text-measure.ts flattenLeaves so measurement skips transforms on empty text (matching paint.ts and Ink:34), and converts screen-reader.ts squashTextContent to use forEach-with-index so the nested-Transform index is correct in SR mode too (was hardcoded 0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(parity): ledger — G21 pr-open, reconcile G20 merged Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -291,6 +291,22 @@ describe("Text aria props", () => {
|
||||
});
|
||||
|
||||
describe("Transform accessibility", () => {
|
||||
// G21 follow-up, finding 2: squashTextContent must pass the transform's
|
||||
// positional sibling index (not hardcoded 0) so SR output matches paint.
|
||||
test("nested <Transform> as 2nd child of <Text> gets index 1 in screen-reader mode", () => {
|
||||
const output = renderToString(
|
||||
defineComponent(() => () => (
|
||||
<Text>
|
||||
a<Transform transform={(s: string, i: number) => `${s}[${i}]`}>b</Transform>
|
||||
</Text>
|
||||
)),
|
||||
{ isScreenReaderEnabled: true },
|
||||
);
|
||||
// Transform is the 2nd child (index 1) of the Text node — must receive 1,
|
||||
// not 0, matching paint.ts and Ink squash-text-nodes.ts:13,38 behavior.
|
||||
expect(output).toBe("ab[1]");
|
||||
});
|
||||
|
||||
test("renders children normally when screen reader is disabled", () => {
|
||||
const output = renderToString(
|
||||
defineComponent(() => () => (
|
||||
|
||||
Reference in New Issue
Block a user