Skip to content

Commit

Permalink
Fix for Issue #6109 - aria-current has incorrect value "true" (#6118)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
brandontruggles authored and timdorr committed May 8, 2018
1 parent fcc662a commit 2d3c68b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/react-router-dom/modules/NavLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ NavLink.propTypes = {

NavLink.defaultProps = {
activeClassName: "active",
"aria-current": "true"
"aria-current": "page"
};

export default NavLink;
8 changes: 4 additions & 4 deletions packages/react-router-dom/modules/__tests__/NavLink-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("NavLink", () => {
expect(a.style.color).toBe(activeStyle.color);
});

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

it("applies the override aria-current value when given", () => {
ReactDOM.render(
<MemoryRouter initialEntries={["/pizza"]}>
<NavLink to="/pizza" activeClassName="selected" aria-current="page">
<NavLink to="/pizza" activeClassName="selected" aria-current="true">
Pizza!
</NavLink>
</MemoryRouter>,
node
);
const a = node.getElementsByTagName("a")[0];
expect(a.getAttribute("aria-current")).toEqual("page");
expect(a.getAttribute("aria-current")).toEqual("true");
});

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

0 comments on commit 2d3c68b

Please sign in to comment.