From 5aaf224486ddc7f2993aa05396307a30f7a32895 Mon Sep 17 00:00:00 2001 From: Denys Kuchma Date: Wed, 21 Oct 2026 20:53:03 +0200 Subject: [PATCH] keep plain text nodes in compactAriaSnapshot --- lib/aria.js | 1 + test/unit/aria_test.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/aria.js b/lib/aria.js index 4535ddf7d..fa7747d6d 100644 --- a/lib/aria.js +++ b/lib/aria.js @@ -121,6 +121,7 @@ function dropEmpty(nodes) { const children = dropEmpty(node.children) if (INTERACTIVE_ROLES.has(node.role)) return [{ ...node, children }] if (children.length > 0) return [{ ...node, children }] + if (node.value !== undefined && node.value !== null && String(node.value).trim()) return [{ ...node, children }] return [] }) } diff --git a/test/unit/aria_test.js b/test/unit/aria_test.js index fb3661465..37f27d3a4 100644 --- a/test/unit/aria_test.js +++ b/test/unit/aria_test.js @@ -35,4 +35,11 @@ describe('aria', () => { expect(compactAriaSnapshot(before)).to.include('textbox "Promo code"') expect(diffAriaSnapshots(before, after)).to.include('removed: 1 interactive elements') }) + + it('keeps plain text nodes when compacting', () => { + const snapshot = ['- list:', ' - listitem:', ' - checkbox', ' - text: buy milk', '- text: 1 item left!'].join('\n') + const compacted = compactAriaSnapshot(snapshot) + expect(compacted).to.include('text: buy milk') + expect(compacted).to.include('text: 1 item left!') + }) })