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.3 diff #3

Closed
wants to merge 22 commits into from
Closed
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
da2deae
changed package name to denote DAISY fork
danielweck Jan 19, 2021
bdcf58d
initial patching (scripts/axe-patch-is-aria-role-allowed.js scripts/a…
danielweck Jan 19, 2021
5830ea9
Mocha fast bail
danielweck Jan 19, 2021
8b3740d
semver is same as Axe Core but with DAISY addon suffix. Also added NP…
danielweck Jan 19, 2021
723b98a
semver is reflected in auto-generated doc
danielweck Jan 19, 2021
2e70235
added unit tests for implicit/explicit and DPUB role parsing
danielweck Jan 19, 2021
4ce706d
Scoped NPM package name, and files selection for NPM publish
danielweck Jan 19, 2021
1c9a0b2
NPM public publish
danielweck Jan 19, 2021
6590f7f
Merge branch 'v4.1.1_DAISY' into v4.1.2_DAISY
danielweck Feb 16, 2021
ea67596
rules MD
danielweck Feb 16, 2021
e04a57a
ignore epub:type
danielweck Feb 18, 2021
af3e209
Merge branch 'v4.1.2_DAISY' into v4.1.3_DAISY
danielweck Mar 10, 2021
161d97e
Unit tests require package.json version without canary or arbitrary e…
danielweck Mar 10, 2021
2a6ab7e
landmark-one-main now with page-no-duplicate-main in addition to page…
danielweck Mar 10, 2021
dae726f
doc: landmark-one-main now with page-no-duplicate-main in addition to…
danielweck Mar 10, 2021
2b5bb2d
intermediary commit (Axe hook seems to stash things in the working co…
danielweck Mar 10, 2021
6121f22
main element and div with role
danielweck Mar 10, 2021
10be613
added unit test for landmark-no-duplicate-main to pass content with n…
danielweck Mar 10, 2021
72707cf
matching-aria-role check port (untranslated)
danielweck Mar 10, 2021
45529c1
epub-type-has-matching-role pagebreak-label ported from Ace (translat…
danielweck Mar 10, 2021
5e5e6a7
working XHTML unit tests for EPUB in Axe! (port from Ace)
danielweck Mar 11, 2021
e460f1d
page-break label test (check)
danielweck Mar 11, 2021
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
@@ -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);
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);
@@ -16,6 +16,10 @@ function listitemEvaluate(node) {
}

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

this.data({
messageKey: 'roleNotValid'
});
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;
@@ -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);
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.2",
"version": "4.1.2-daisy.0",
"license": "MPL-2.0",
"engines": {
"node": ">=4"
@@ -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"
@@ -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",
@@ -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
@@ -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 }));
});
});

@@ -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() {
3 changes: 2 additions & 1 deletion test/runner.tmpl
Original file line number Diff line number Diff line change
@@ -24,7 +24,8 @@
<script>
mocha.setup({
timeout: 20000,
ui: 'bdd'
ui: 'bdd',
bail: true,
});
var assert = chai.assert;
</script>