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

fix(rules/region): Treat <section> as a landmark if it has an accessible name #640 #642

Merged
merged 2 commits into from
Dec 15, 2017

Conversation

WilcoFiers
Copy link
Contributor

This closes #640.

@@ -26,7 +26,9 @@ function isLandmark (node) {
if (node.hasAttribute('role')) {
return landmarkRoles.includes(node.getAttribute('role').toLowerCase());
} else {
return implicitLandmarks.includes(node.nodeName.toUpperCase());
return implicitLandmarks.some((implicitSelector) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like magic to me. Can you add a comment about what's happening here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like he's electing to use the matchesSelector utility to determine whether the node has an implicit landmark role, instead of simply checking whether the array of of implicit landmark roles includes the nodeName. I'm guessing this wasn't working for all nodes, since the nodeName of an element with an implicit landmark role is often different than the landmark role. E.g., given a <header> element, #nodeName === 'HEADER', but its implicit role is 'banner'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also allows the values in the role's "implicit" entry in the lookup table to be CSS selectors more complex than just the nodeName. E.g., input[type="button"]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'd still love to see a comment in the code for future reading.

Copy link
Contributor

@isner isner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff!

@WilcoFiers WilcoFiers merged commit c11b442 into develop Dec 15, 2017
@WilcoFiers WilcoFiers deleted the region-landmark branch December 15, 2017 10:43
WilcoFiers added a commit that referenced this pull request Dec 15, 2017
…ble name #640 (#642)

* fix(rules/region): Treat <section> as a landmark if it has an accessible name #640

* chore(checks/region): Add clarifying comment
@WilcoFiers
Copy link
Contributor Author

Also merged into 2x

@iamrafan
Copy link
Contributor

@WilcoFiers Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants