-
Notifications
You must be signed in to change notification settings - Fork 788
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
Add rule, landmark-main-is-top-level #462
Conversation
…k in a document is not within another landmark element
if (!role){ | ||
role = axe.commons.aria.implicitRole(parent); | ||
} | ||
if (role && landmarks.indexOf(role) >= 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use !landmarks.includes(role)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will make this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WilcoFiers
We have updated the pull request with requested changes
@@ -0,0 +1,16 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this rule from the PR.
], | ||
"metadata": { | ||
"description": "Each main landmark in a document must not be nested in another landmark", | ||
"help": "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to fill this out too. Description says what the rule does, help gives a hint on how to fix the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help text also goes in the aXe extension sidebar where we list out the violations.
"metadata": { | ||
"impact": "moderate", | ||
"messages": { | ||
"pass": "Main landmark is top level", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a full sentence for both texts.
while (parent){ | ||
var role = parent.getAttribute('role'); | ||
if (!role){ | ||
role = axe.commons.aria.implicitRole(parent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too strict. There are roles that can certainly be permitted, off the top of my head: form
, application
, presentation
. Probably a bunch more. Can you go through the list and make sure those kind of things get ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIlco,
- In ARIA 1.1 application and presentation roles are not considered landmarks.
- In the case of a form landmark:
2.a Form landmarks should be fairly rare, there is discussion in the ARIA and HTML5 working groups that form landmarks should/must have an accessible name to be considered a landmark or at least useful, since without knowing what the form is about the navigation feature is somewhat limited since getting to form controls is easy from screen readers and makes the landmark more of a distraction than a useful feature.
2.b Forms are typically just one part of a page so should be in another landmark, the main landmark is what people will be looking for, not a form landmark. In general Form landmarks should only be used if there are multiple forms on a page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jongund Both of those suggestions make sense to me. Seeing as it's still an open discussion if forms should be a landmark, make an exception for this rule. That one is particularly relevant for the region
rule. You can adjust the type of application and presentation in lib/commons/aria/index
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wilco,
We will modify the file lib/commons/aria/index for role application:
type: 'landmark' to type: 'structure'
role presentation is already has type: 'structure' so no change need for it.
… update aria index file so application type is structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jongund @ssanaul I've left a few more comments, listing some of the changes that didn't get done correctly yet. These PRs have been open for a while now. I'd like to make sure we can merge them in soon. What are your plans for this? If you want, we can set up a call and get through these last few issues.
"metadata": { | ||
"impact": "moderate", | ||
"messages": { | ||
"pass": "The main landmark is top level.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a correct sentence, please use "is as the top level."
], | ||
"metadata": { | ||
"description": "Each main landmark in a document must not be nested in another landmark", | ||
"help": "The main landmark in this document should not be contained within another landmark" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too wordy and won't fit well into the extension UI. I'd suggestion: "The main landmark should not be in another landmark"
</head> | ||
<body> | ||
<p>This iframe is also a violation</p> | ||
<div role = "form"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be a failure. Neither should role="application". Make sure there is a test for that too.
if (!role){ | ||
role = axe.commons.aria.implicitRole(parent); | ||
} | ||
if (role && landmarks.indexOf(role) >= 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use .includes()
instead.
@@ -0,0 +1,13 @@ | |||
var landmarks = axe.commons.aria.getRolesByType('landmark'); | |||
var parent = node.parentElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR has been open for a while now. Since than, we've merged shadow DOM in. It has a different method of getting at parent nodes. Please use axe.commons.dom.getComposedParent()
. That way this check will look passed shadow DOM boundaries. You'll have to rebase to get the latest on develop into this branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jongund This line still uses node.parentElement
, please fix this too.
Wilco,
I am meeting with the student later today and we will:
1. Make the make the changes outlined in this e-mail
2. Update the pull requests to remove the obsolete proposed rules
If there are still additional issues after the changes maybe we can schedule a call to work on the remaining issues.
Jon
From: Wilco Fiers <notifications@github.com>
Reply-To: dequelabs/axe-core <reply@reply.github.com>
Date: Wednesday, August 23, 2017 at 4:38 AM
To: dequelabs/axe-core <axe-core@noreply.github.com>
Cc: Jon Gunderson <jongund@illinois.edu>, Mention <mention@noreply.github.com>
Subject: Re: [dequelabs/axe-core] Add rule, landmark-main-is-top-level (#462)
@WilcoFiers commented on this pull request.
@jongund<https://github.com/jongund> @ssanaul<https://github.com/ssanaul> I've left a few more comments, listing some of the changes that didn't get done correctly yet. These PRs have been open for a while now. I'd like to make sure we can merge them in soon. What are your plans for this? If you want, we can set up a call and get through these last few issues.
________________________________
In lib/checks/keyboard/main-is-top-level.json<#462 (comment)>:
@@ -0,0 +1,11 @@
+{
+ "id": "main-is-top-level",
+ "evaluate": "main-is-top-level.js",
+ "metadata": {
+ "impact": "moderate",
+ "messages": {
+ "pass": "The main landmark is top level.",
This isn't a correct sentence, please use "is as the top level."
________________________________
In lib/rules/landmark-main-is-top-level.json<#462 (comment)>:
@@ -0,0 +1,16 @@
+{
+ "id": "landmark-main-is-top-level",
+ "selector": "main,[role=main]",
+ "tags": [
+ "best-practice"
+ ],
+ "metadata": {
+ "description": "Each main landmark in a document must not be nested in another landmark",
+ "help": "The main landmark in this document should not be contained within another landmark"
This is too wordy and won't fit well into the extension UI. I'd suggestion: "The main landmark should not be in another landmark"
________________________________
In test/integration/full/landmark-main-is-top-level/frames/level2-a.html<#462 (comment)>:
@@ -0,0 +1,15 @@
+<!doctype html>
+<html id="violation4">
+<head>
+ <meta charset="utf8">
+ <script src="/axe.js"></script>
+</head>
+<body>
+ <p>This iframe is also a violation</p>
+ <div role = "form">
This shouldn't be a failure. Neither should role="application". Make sure there is a test for that too.
________________________________
In lib/checks/keyboard/main-is-top-level.js<#462 (comment)>:
@@ -0,0 +1,13 @@
+var landmarks = axe.commons.aria.getRolesByType('landmark');
+var parent = node.parentElement;
+while (parent){
+ var role = parent.getAttribute('role');
+ if (!role){
+ role = axe.commons.aria.implicitRole(parent);
+ }
+ if (role && landmarks.indexOf(role) >= 0){
Use .includes() instead.
________________________________
In lib/checks/keyboard/main-is-top-level.js<#462 (comment)>:
@@ -0,0 +1,13 @@
+var landmarks = axe.commons.aria.getRolesByType('landmark');
+var parent = node.parentElement;
This PR has been open for a while now. Since than, we've merged shadow DOM in. It has a different method of getting at parent nodes. Please use axe.commons.dom.getComposedParent(). That way this check will look passed shadow DOM boundaries. You'll have to rebase to get the latest on develop into this branch.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#462 (review)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABcE7N_akj2vx5TBgadPCjJavPSNyGihks5sa_MngaJpZM4OkJzP>.
|
Wilco,
In our discussion:
jongund<https://github.com/jongund> 6 days ago <#462 (comment)>
WIlco,
1. In ARIA 1.1 application and presentation roles are not considered landmarks.
2. In the case of a form landmark:
2.a Form landmarks should be fairly rare, there is discussion in the ARIA and HTML5 working groups that form landmarks should/must have an accessible name to be considered a landmark or at least useful, since without knowing what the form is about the navigation feature is somewhat limited since getting to form controls is easy from screen readers and makes the landmark more of a distraction than a useful feature.
2.b Forms are typically just one part of a page so should be in another landmark, the main landmark is what people will be looking for, not a form landmark. In general Form landmarks should only be used if there are multiple forms on a page.
Top of Form
Bottom of Form
[WilcoFiers]<https://github.com/WilcoFiers>
WilcoFiers<https://github.com/WilcoFiers> 5 days ago <#462 (comment)>
Contributor
@jongund<https://github.com/jongund> Both of those suggestions make sense to me. Seeing as it's still an open discussion if forms should be a landmark, make an exception for this rule. That one is particularly relevant for the region rule. You can adjust the type of application and presentation in lib/commons/aria/index.
It sounded like you agreed to change “application” in /lib/commons/aria/index.js to not be a landmark and that is part of our pull request and that you seemed to agree that FORM landmark restriction was also OK, since FORM landmarks should be rare in practice and a MAIN landmark would probably be better for identifying a page that is mostly a form.
So the test for bening contained in a FORM landmark should fail and APPLICATION does need to be tested because it is not a landmark in ARIA 1.1.
Jon
________________________________
In test/integration/full/landmark-main-is-top-level/frames/level2-a.html<#462 (comment)>:
@@ -0,0 +1,15 @@
+<!doctype html>
+<html id="violation4">
+<head>
+ <meta charset="utf8">
+ <script src="/axe.js"></script>
+</head>
+<body>
+ <p>This iframe is also a violation</p>
+ <div role = "form">
This shouldn't be a failure. Neither should role="application". Make sure there is a test for that too.
|
We have updated the pull request, including changing the messaging and using axe.commons.getComposedParent. The only outstanding issue seems to be whether a MAIN landmark can be contained by a FORM landmark. Based on FORM landmarks being rare and if a FORM is the primary content of a page, the MAIN landmark would probably be as good if not better , since users ae looking for MAIN landmarks. So the tests still view FORM as a failure. Do we want to discuss it in a teleconference? |
We updated the rule to use:
|
@jongund The tests aren't passing yet. Be sure to run |
Anymore questions or issues with this pull request? What is the status of accepting this rule? |
@jongund We're a little busy with the 2.4 releases at the moment. We certainly haven't forgotten about these PRs and will get to reviewing them as soon as possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there! Just a few more small changes. One of the tests is failing still. Please make sure all tests are passing before you request a review next time.
var div = document.createElement('div'); | ||
var shadow = div.attachShadow({ mode: 'open' }); | ||
shadow.innerHTML = '<main>Main content</main>'; | ||
var checkArgs = checkSetup(div); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will select the div, not the <main>
element. This should be checkSetup(shadow.querySelector('main'));
</head> | ||
<body> | ||
<p>This iframe should fail, too</p> | ||
<div role = "complementary"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use spaces in attributes.
|
||
describe('violations', function () { | ||
it('should find 1', function () { | ||
assert.lengthOf(results.violations, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a node count check too:
assert.lengthOf(results.violations[0].nodes, 2);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssanaul This issue isn't addressed yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought 3e5c6ad resolved it. It checks for 4 nodes because I believe there are 4 violations. @WilcoFiers
lib/commons/aria/index.js
Outdated
@@ -189,7 +189,7 @@ lookupTables.role = { | |||
context: null | |||
}, | |||
'application': { | |||
type: 'landmark', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is causing the following test to fail, be sure to fix that:
1) table.isDataTable should be true if the table has a landmark role application:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WilcoFiers
In ARIA 1.1, 'application' is not a landmark role.
https://www.w3.org/TR/wai-aria-1.1/#application
The new superclass role is 'structure'.
Can you update the 'develop' branch to meet the ARIA 1.1 specification?
This is the warning message I'm receiving currently. Is this what you're seeing as well @WilcoFiers ? |
@ssanaul you can always fire up the tests in a browser using |
@ssanaul @jongund What's the status of this PR? |
Wilco,
Sulaiman is trying to setup a meeting with Marcy Sutton to try to debug why the integration tests are failing.
It seems we need a little more help with configuring the test cases correctly.
Do you have any time to meet with us this week to review our code with us?
Jon
From: Wilco Fiers <notifications@github.com>
Reply-To: dequelabs/axe-core <reply@reply.github.com>
Date: Tuesday, October 10, 2017 at 7:07 AM
To: dequelabs/axe-core <axe-core@noreply.github.com>
Cc: Jon Gunderson <jongund@illinois.edu>, Mention <mention@noreply.github.com>
Subject: Re: [dequelabs/axe-core] Add rule, landmark-main-is-top-level (#462)
@ssanaul<https://github.com/ssanaul> @jongund<https://github.com/jongund> What's the status of this PR?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#462 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABcE7Lh9ffehEvYql-NzIrxbhU9Xes6pks5sq1ACgaJpZM4OkJzP>.
|
Is there anything I've excluded from this PR? I thought I had addressed all review comments. |
I'm still seeing two pretty simple comments from Wilco that weren't addressed, otherwise looks good to me.
|
Ok, I think that last commit should have resolved everything. Although, I think the suggested node count check |
var parent = axe.commons.dom.getComposedParent(node); | ||
while (parent){ | ||
var role = parent.getAttribute('role'); | ||
if (!role && (parent.tagName.toLowerCase() !== 'form')){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to work with role=form
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does line 5 not accomplish that?
@ssanaul thank you for your contribution!!! |
* init * feat: add new rule, landmark-no-more-than-one-main * test(landmark-at-least-one-main): updated integration tests for check * feat(landmark-main-is-top-level): add rule ensuring each main landmark in a document is not within another landmark element * refactor(landmark-main-is-top-level): change help messages * feat(landmark-main-is-top-level): change a function used in check and update aria index file so application type is structure * refactor(main-is-top-level): change pass/fail messages * refactor(landmark-main-is-top-level): change description/help messages * feat(main-is-top-level): update check for shadow dom features * fix(main-is-top-level): update check to ignore form as a landmark * fix: edit incorrect usage of getComposedParent * test: add unit test to check if main landmark in shadow dom is top level * style: remove spaces in attributes * fix: update test so that checkSetup passes in correct argument * test: add test to ensure correct number of violations nodes * fix: revert 'application' type to landmark * style: remove spaces in attributes * fix: allow main landmark to be in form
…/react/examples/shadow-dom (dequelabs#462) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This rule ensures that each main landmark in a document is not nested within another landmark element. Once again, please let me know if there is anything you would like to see differently.