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: Allow div groups for dlitem rule #1284

Merged
merged 3 commits into from
Jan 7, 2019
Merged

fix: Allow div groups for dlitem rule #1284

merged 3 commits into from
Jan 7, 2019

Conversation

WilcoFiers
Copy link
Contributor

@WilcoFiers WilcoFiers commented Dec 19, 2018

Allow grouping in divs for the dlitem rule.

Closes #1265

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: << Marcy Sutton >>

@WilcoFiers WilcoFiers requested a review from a team as a code owner December 19, 2018 11:09

// Unlike with UL|OL+LI, DT|DD must be in a DL
if (parentTagName !== 'DL') {
return false;
}

const parentRole = (parent.getAttribute('role') || '').toLowerCase();
if (!parentRole || !axe.commons.aria.isValidRole(parentRole)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isValidRole is done by aria.getRole(), in case you're wondering.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm surprised it works with the noImplicit: true, can you explain that bit? This applies to native elements as well as bolt-on roles, right? The tests seem to pass, so 🤷‍♀️

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 requirements here are: It needs to be in a dl, and if that dl has a role attribute, it can only be a list. So what's happening is first I check the parentTagName, and then I check if the explicit role (which is what we get from noImplicit: true is null or 'list'.

});
});

it('returns false if the dd/dt is in a div with a role with a dl as grandparent', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add with a list role to the test name because that's the important bit

@@ -88,4 +144,17 @@ describe('dlitem', function() {
assert.isFalse(checks.dlitem.evaluate.apply(null, checkArgs));
}
);

(shadowSupport.v1 ? it : xit)(
'should return truewhen the item is grouped in dl > div',
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a space to the test name: true when. It should also mention Shadow DOM

Copy link
Contributor

@marcysutton marcysutton left a comment

Choose a reason for hiding this comment

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

Just a few comments about test names, otherwise it looks good

@WilcoFiers WilcoFiers dismissed marcysutton’s stale review December 30, 2018 10:29

Comments resolved. Please take another look.

@WilcoFiers WilcoFiers merged commit d76cd36 into develop Jan 7, 2019
@WilcoFiers WilcoFiers deleted the dd-fix branch January 7, 2019 15:04
36degrees added a commit to alphagov/govuk-frontend that referenced this pull request Sep 8, 2021
We wrap each name-value group in the summary list's `<dl>` with a grouping `<div>` element, which is valid according to the current WHATWG HTML spec [1].

At the time we wrote these tests, this was a relatively recent change to the HTML spec, and the axe rules had not been updated to allow it.

Since then, the underlying axe rules have been updated to allow wrapping `<div>` elements [2], so we no longer need to disable the `dlitem` and `definition-list` (released in axe-core 3.2.0 [3])

[1]: https://html.spec.whatwg.org/multipage/grouping-content.html#the-dl-element
[2]: dequelabs/axe-core#1284
[3]: https://github.com/dequelabs/axe-core/blob/develop/CHANGELOG.md#320-2019-03-04
36degrees added a commit to alphagov/govuk-frontend that referenced this pull request Oct 14, 2021
We wrap each name-value group in the summary list's `<dl>` with a grouping `<div>` element, which is valid according to the current WHATWG HTML spec [1].

At the time we wrote these tests, this was a relatively recent change to the HTML spec, and the axe rules had not been updated to allow it.

Since then, the underlying axe rules have been updated to allow wrapping `<div>` elements [2], so we no longer need to disable the `dlitem` and `definition-list` (released in axe-core 3.2.0 [3])

[1]: https://html.spec.whatwg.org/multipage/grouping-content.html#the-dl-element
[2]: dequelabs/axe-core#1284
[3]: https://github.com/dequelabs/axe-core/blob/develop/CHANGELOG.md#320-2019-03-04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants