Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR][SR Tree] Update tree to use innerText #2090

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-experts-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/perseus-editor": patch
---

[SR][sr tree] Update tree to use innerText
Original file line number Diff line number Diff line change
Expand Up @@ -340,34 +340,6 @@ describe("fetchAriaLabels", () => {
]);
});

test("should include hidden descriptions", () => {
// Arrange
const {container} = render(
<div>
<div aria-describedby="description1 description2">label1</div>
<div id="description1">description1 content</div>
<div id="description2" style={{display: "hidden"}}>
description2 content
</div>
</div>,
);

// Act
const result = getAccessibilityAttributes(container);

// Assert
expect(result).toEqual([
{
roleOrTag: "div",
className: "",
attributes: [
{name: "description", value: "description1 content"},
{name: "description", value: "description2 content"},
],
},
]);
});

test("should not include descriptions that are not found", () => {
// Arrange
const {container} = render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ export function getAccessibilityAttributes(
const descriptions = ariaDescribedby.split(/ +/);
for (const description of descriptions) {
const descriptionString =
// Use textContent instead of innerText to get the text
// even if it is hidden.
document.getElementById(description)?.textContent;
document.getElementById(description)?.innerText;

if (descriptionString) {
elementAttributes.push({
Expand Down
Loading