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

[WIP] [DO NOT MERGE] v4.1.1 diff #1

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 100 additions & 100 deletions doc/rule-descriptions.md

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions lib/checks/aria/aria-required-children-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ import { hasContentVirtual, idrefs } from '../../commons/dom';
* Get all owned roles of an element
*/
function getOwnedRoles(virtualNode) {
const parentRole = getRole(virtualNode, { dpub: true });

const ownedRoles = [];
const ownedElements = getOwnedVirtual(virtualNode);
for (let i = 0; i < ownedElements.length; i++) {
let ownedElement = ownedElements[i];
let role = getRole(ownedElement);
let role = getRole(ownedElement, { dpub: true });

// if owned node has no role or is presentational we keep
// parsing the descendant tree. this means intermediate roles
// between a required parent and child will fail the check
if (['presentation', 'none', null].includes(role)) {
if (
['presentation', 'none', null].includes(role) ||
(['list'].includes(role) &&
['doc-bibliography', 'doc-endnotes'].includes(parentRole))
) {
ownedElements.push(...ownedElement.children);
} else if (role) {
ownedRoles.push(role);
Expand Down
6 changes: 5 additions & 1 deletion lib/checks/lists/listitem-evaluate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getComposedParent } from '../../commons/dom';
import { isValidRole } from '../../commons/aria';
import { getRoleType, isValidRole } from '../../commons/aria';

function listitemEvaluate(node) {
const parent = getComposedParent(node);
Expand All @@ -16,6 +16,10 @@ function listitemEvaluate(node) {
}

if (parentRole && isValidRole(parentRole)) {
if (getRoleType(parentRole) === 'list') {
return true;
}

this.data({
messageKey: 'roleNotValid'
});
Expand Down
5 changes: 3 additions & 2 deletions lib/checks/lists/only-listitems-evaluate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isVisible } from '../../commons/dom';
import { getRole } from '../../commons/aria';
import { getRole, getRoleType } from '../../commons/aria';

function onlyListitemsEvaluate(node, options, virtualNode) {
let hasNonEmptyTextNode = false;
Expand All @@ -24,7 +24,8 @@ function onlyListitemsEvaluate(node, options, virtualNode) {
isEmpty = false;
const isLi = actualNode.nodeName.toUpperCase() === 'LI';
const role = getRole(vNode);
const isListItemRole = role === 'listitem';
const isListItemRole =
role === 'listitem' || getRoleType(role) === 'listitem';

if (!isLi && !isListItemRole) {
badNodes.push(actualNode);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "axe-core",
"name": "@daisy/axe-core-for-ace",
"description": "Accessibility engine for automated Web UI testing",
"version": "4.1.1",
"version": "4.1.1-daisy.0",
"license": "MPL-2.0",
"engines": {
"node": ">=4"
Expand Down Expand Up @@ -50,6 +50,15 @@
],
"main": "axe.js",
"typings": "axe.d.ts",
"files": [
"LICENSE",
"README.md",
"CHANGELOG.md",
"locales/**/*",
"axe.js",
"axe.min.js",
"axe.d.ts"
],
"standard-version": {
"scripts": {
"postbump": "npm ci && npm run sri-update"
Expand All @@ -64,6 +73,7 @@
"eslint": "eslint --color --format stylish '{lib,test,build,doc}/**/*.js' 'Gruntfile.js'",
"test:headless": "node ./build/test/headless",
"test": "tsc && grunt test",
"test-fast": "tsc && grunt test-fast",
"test:examples": "node ./doc/examples/test-examples",
"test:locales": "mocha test/test-locales.js",
"test:rule-help-version": "mocha test/test-rule-help-version.js",
Expand Down Expand Up @@ -149,5 +159,8 @@
"prettier --write",
"git add"
]
},
"publishConfig": {
"access": "public"
}
}
68 changes: 67 additions & 1 deletion test/commons/aria/get-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,29 @@ describe('aria.getRole', function() {
assert.equal(aria.getRole(node, { dpub: true }), 'doc-chapter');
});

it('does not returns DPUB roles with `dpub: false`', function() {
it('returns DPUB roles with `dpub: true` whilst ignoring implicit roles', function() {
var node = document.createElement('li');
node.setAttribute('role', 'doc-chapter');
flatTreeSetup(node);
assert.equal(aria.getRole(node, { dpub: true }), 'doc-chapter');
});

it('returns non-DPUB implicit roles with `dpub: false/undefined`', function() {
var node = document.createElement('li');
node.setAttribute('role', 'doc-chapter');
var parentNode = document.createElement('div');
parentNode.appendChild(node);
flatTreeSetup(parentNode);
assert.equal(aria.getRole(node, { dpub: false }), 'listitem');
assert.equal(aria.getRole(node, { dpub: undefined }), 'listitem');
});

it('does not returns DPUB roles with `dpub: false/undefined`', function() {
var node = document.createElement('section');
node.setAttribute('role', 'doc-chapter');
flatTreeSetup(node);
assert.isNull(aria.getRole(node, { dpub: false }));
assert.isNull(aria.getRole(node, { dpub: undefined }));
});
});

Expand Down Expand Up @@ -379,6 +397,54 @@ describe('aria.getRole', function() {
'doc-chapter'
);
});

it('respect the `dpub: false/undefined` option, whilst skipping the implicit roles due to non-abstract explicit role', function() {
var node = document.createElement('li');
node.setAttribute('role', 'doc-chapter region');
var parentNode = document.createElement('div');
parentNode.appendChild(node);
flatTreeSetup(parentNode);
assert.equal(
aria.getRole(node, { fallback: true, dpub: false }),
'region'
);
assert.equal(
aria.getRole(node, { fallback: true, dpub: undefined }),
'region'
);
});

it('respect the `dpub: false/undefined` option, whilst ignoring the implicit roles and abstract explicit role', function() {
var node = document.createElement('li');
node.setAttribute('role', 'doc-chapter section');
var parentNode = document.createElement('div');
parentNode.appendChild(node);
flatTreeSetup(parentNode);
assert.isNull(
aria.getRole(node, { noImplicit: true, fallback: true, dpub: false })
);
assert.isNull(
aria.getRole(node, {
noImplicit: true,
fallback: true,
dpub: undefined
})
);
});

it('respect the `dpub: false/undefined` option', function() {
var node = document.createElement('div');
node.setAttribute('role', 'doc-chapter region');
flatTreeSetup(node);
assert.equal(
aria.getRole(node, { fallback: true, dpub: false }),
'region'
);
assert.equal(
aria.getRole(node, { fallback: true, dpub: undefined }),
'region'
);
});
});

describe('noPresentational is honored', function() {
Expand Down
3 changes: 2 additions & 1 deletion test/runner.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<script>
mocha.setup({
timeout: 20000,
ui: 'bdd'
ui: 'bdd',
bail: true,
});
var assert = chai.assert;
</script>
Expand Down