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

feat: new rule landmark-complementary-is-top-level #1239

Merged
merged 6 commits into from
Dec 4, 2018

Conversation

marcysutton
Copy link
Contributor

Best practice requiring asides and complementary landmarks to be top level, in line with the ARIA Authoring Practices Guide.

Closes #795

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Has documentation updated, a DU ticket, or requires no documentation change
  • Includes new tests, or was unnecessary
  • Code is reviewed for security by: << Name here >>

@marcysutton marcysutton requested a review from a team as a code owner November 14, 2018 17:43
@marcysutton marcysutton force-pushed the landmark-complementary-top-level branch 2 times, most recently from cc291e6 to 07ae611 Compare November 14, 2018 20:56
@@ -1,7 +1,7 @@
const nativeScopeFilter = 'article, aside, main, nav, section';

// Filter elements that, within certain contexts, don't map their role.
// e.g. a <footer> inside a <main> is not a banner, but in the <body> context it is
// e.g. a <header> inside a <main> is not a banner, but in the <body> context it is
return (
node.hasAttribute('role') ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be extracted to "selector": "[role]"?

Copy link
Contributor Author

@marcysutton marcysutton Nov 14, 2018

Choose a reason for hiding this comment

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

You mean in the JSON? The only reason this file has edits is it had a typo in it...

Edit: I don't think we actually need this file for asides.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up not using this file, and the only thing I changed in it was a comment typo. Leaving as-is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I had to look it up too, but yes aside always maps to role= complementary, unlike footer and header which only map to a role if they are scoped to the body.

var aside = document.createElement('div');
aside.setAttribute('role', 'complementary');
aside.appendChild(mainLandmark);
fixture.appendChild(aside);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: I know, there are multiple tests written with DOM api like above using createElement, appendChild etc. I found that using the testutils.fixtureSetup() function to be helpful for this, and saves us a few lines and also makes it easy to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the tests, you're right that they were more difficult to read!

@@ -23,6 +23,16 @@ describe('landmark-is-top-level', function() {
assert.deepEqual(checkContext._data, { role: 'main' });
});

it('should return false if the complementary landmark is in another landmark', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, just had a thought, what happens if the first header element after body element happens with in shadowDOM?

Question being, do we need to consider shadowDOM for this rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check already has Shadow DOM coverage.

jeeyyy
jeeyyy previously requested changes Nov 14, 2018
Copy link
Contributor

@jeeyyy jeeyyy left a comment

Choose a reason for hiding this comment

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

See comments.

Also, seems like CI was blocked to move ahead on the integration test.

Output from CI:

http://localhost:9876/test/integration/full/landmark-complementary-is-top-level/landmark-complementary-is-top-level-fail.html
>> passes: 5, failures: 0, duration: 0.025s

Too long with no output (exceeded 10m0s)

It may be worth running circle ci locally to test the same. The command is circleci local execute --job test

@marcysutton
Copy link
Contributor Author

marcysutton commented Nov 14, 2018

@JKODU thanks for the tip. I almost got it working after some fiddling with my machine, but now it's stuck on PhantomJS for some reason.

Best practice requiring asides and complementary landmarks to be top level, in line with the ARIA Authoring Practices Guide.

Closes #795
@marcysutton marcysutton force-pushed the landmark-complementary-top-level branch from 07ae611 to 65a8485 Compare November 19, 2018 18:49
Marcy Sutton added 4 commits November 19, 2018 16:22
The first version of this rule included a body context check copied over from the top-level-banner-landmark rule, and it made very flaky iframe tests. It wasn't really necessary since aside doesn't have the same behavior as header/role=banner.
@@ -1,7 +1,7 @@
const nativeScopeFilter = 'article, aside, main, nav, section';

// Filter elements that, within certain contexts, don't map their role.
// e.g. a <footer> inside a <main> is not a banner, but in the <body> context it is
// e.g. a <header> inside a <main> is not a banner, but in the <body> context it is
return (
node.hasAttribute('role') ||
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to look it up too, but yes aside always maps to role= complementary, unlike footer and header which only map to a role if they are scoped to the body.

@marcysutton marcysutton merged commit 328ca2c into develop Dec 4, 2018
@marcysutton marcysutton deleted the landmark-complementary-top-level branch December 4, 2018 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants