Skip to content

Commit 2d3c68b

Browse files
brandontrugglestimdorr
authored andcommitted
Fix for Issue #6109 - aria-current has incorrect value "true" (#6118)
* Added 'false' as a valid value for aria-current in NavLink. Also made the default value 'page' instead of 'true'. * Remove "false" string as a permitted aria-current value.
1 parent fcc662a commit 2d3c68b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/react-router-dom/modules/NavLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ NavLink.propTypes = {
7373

7474
NavLink.defaultProps = {
7575
activeClassName: "active",
76-
"aria-current": "true"
76+
"aria-current": "page"
7777
};
7878

7979
export default NavLink;

packages/react-router-dom/modules/__tests__/NavLink-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("NavLink", () => {
5353
expect(a.style.color).toBe(activeStyle.color);
5454
});
5555

56-
it("applies aria-current of true if no override value is given", () => {
56+
it("applies aria-current of page if no override value is given", () => {
5757
ReactDOM.render(
5858
<MemoryRouter initialEntries={["/pizza"]}>
5959
<NavLink to="/pizza" activeClassName="selected">
@@ -63,20 +63,20 @@ describe("NavLink", () => {
6363
node
6464
);
6565
const a = node.getElementsByTagName("a")[0];
66-
expect(a.getAttribute("aria-current")).toEqual("true");
66+
expect(a.getAttribute("aria-current")).toEqual("page");
6767
});
6868

6969
it("applies the override aria-current value when given", () => {
7070
ReactDOM.render(
7171
<MemoryRouter initialEntries={["/pizza"]}>
72-
<NavLink to="/pizza" activeClassName="selected" aria-current="page">
72+
<NavLink to="/pizza" activeClassName="selected" aria-current="true">
7373
Pizza!
7474
</NavLink>
7575
</MemoryRouter>,
7676
node
7777
);
7878
const a = node.getElementsByTagName("a")[0];
79-
expect(a.getAttribute("aria-current")).toEqual("page");
79+
expect(a.getAttribute("aria-current")).toEqual("true");
8080
});
8181

8282
it("handles locations without a pathname", () => {

0 commit comments

Comments
 (0)