Skip to content

Commit

Permalink
Merge pull request #2654 from dequelabs/release-4.1.1
Browse files Browse the repository at this point in the history
chore: Release 4.1.1
  • Loading branch information
WilcoFiers authored Nov 20, 2020
2 parents 0e624cd + d72e2c3 commit 7da2c51
Show file tree
Hide file tree
Showing 45 changed files with 264 additions and 207 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [4.1.1](https://github.com/dequelabs/axe-core/compare/v4.1.0...v4.1.1) (2020-11-19)

### Bug Fixes

- remove axios import ([#2653](https://github.com/dequelabs/axe-core/issues/2653)) ([2d20cde](https://github.com/dequelabs/axe-core/commit/2d20cdee819265f3c4efcb3ccb61da0a9a88981c))
- **color-contrast:** greatly improve color-contrast-matches speed. add aria/get-accessible-ref ([#2635](https://github.com/dequelabs/axe-core/issues/2635)) ([ba174bd](https://github.com/dequelabs/axe-core/commit/ba174bd5496d7146c1baf982cb762444cda26cff))

## [4.1.0](https://github.com/dequelabs/axe-core/compare/v4.0.2...v4.1.0) (2020-11-13)

### Features
Expand Down
9 changes: 6 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ module.exports = function(grunt) {
});
return driverTests;
})(),
clean: ['dist', 'tmp', 'axe.js', 'axe.*.js'],
clean: {
core: ['dist', 'tmp/core', 'tmp/rules.js', 'axe.js', 'axe.*.js'],
tests: ['tmp/integration-tests.js']
},
babel: {
options: {
compact: false
Expand Down Expand Up @@ -240,7 +243,7 @@ module.exports = function(grunt) {
},
tests: {
files: ['test/**/*.js', 'test/integration/**/!(index).{html,json}'],
tasks: ['testconfig', 'fixture']
tasks: ['clean:tests', 'testconfig', 'fixture']
}
},
testconfig: {
Expand Down Expand Up @@ -353,7 +356,7 @@ module.exports = function(grunt) {

grunt.registerTask('translate', ['validate', 'esbuild', 'add-locale']);
grunt.registerTask('build', [
'clean',
'clean:core',
'validate',
'esbuild',
'configure',
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axe-core",
"version": "4.1.0",
"version": "4.1.1",
"contributors": [
{
"name": "David Sturley",
Expand Down
3 changes: 1 addition & 2 deletions lib/checks/aria/aria-errormessage-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ function ariaErrormessageEvaluate(node, options) {
idref.getAttribute('role') === 'alert' ||
idref.getAttribute('aria-live') === 'assertive' ||
idref.getAttribute('aria-live') === 'polite' ||
tokenList(node.getAttribute('aria-describedby') || '').indexOf(attr) >
-1
tokenList(node.getAttribute('aria-describedby')).indexOf(attr) > -1
);
}
return;
Expand Down
4 changes: 2 additions & 2 deletions lib/checks/generic/attr-non-space-content-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function attrNonSpaceContentEvaluate(node, options = {}, vNode) {
return false;
}

const attribute = vNode.attr(options.attribute) || '';
const attributeIsEmpty = !sanitize(attribute.trim());
const attribute = vNode.attr(options.attribute);
const attributeIsEmpty = !sanitize(attribute);
if (attributeIsEmpty) {
this.data({
messageKey: 'emptyAttr'
Expand Down
4 changes: 1 addition & 3 deletions lib/checks/navigation/unique-frame-title-evaluate.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { sanitize } from '../../commons/text';

function uniqueFrameTitleEvaluate(node, options, vNode) {
var title = sanitize(vNode.attr('title') || '')
.trim()
.toLowerCase();
var title = sanitize(vNode.attr('title')).toLowerCase();
this.data(title);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/checks/shared/doc-has-title-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { sanitize } from '../../commons/text';

function docHasTitleEvaluate() {
var title = document.title;
return !!(title ? sanitize(title).trim() : '');
return !!sanitize(title);
}

export default docHasTitleEvaluate;
73 changes: 73 additions & 0 deletions lib/commons/aria/get-accessible-refs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import getRootNode from '../dom/get-root-node';
import cache from '../../core/base/cache';
import { tokenList } from '../../core/utils';
import standards from '../../standards';
import { sanitize } from '../text/';

const idRefsRegex = /^idrefs?$/;

/**
* Cache all ID references of a node and its children
*/
function cacheIdRefs(node, idRefs, refAttrs) {
if (node.hasAttribute) {
if (node.nodeName.toUpperCase() === 'LABEL' && node.hasAttribute('for')) {
const id = node.getAttribute('for');
idRefs[id] = idRefs[id] || [];
idRefs[id].push(node);
}

for (let i = 0; i < refAttrs.length; ++i) {
const attr = refAttrs[i];
const attrValue = sanitize(node.getAttribute(attr) || '');

if (!attrValue) {
continue;
}

const tokens = tokenList(attrValue);
for (let k = 0; k < tokens.length; ++k) {
idRefs[tokens[k]] = idRefs[tokens[k]] || [];
idRefs[tokens[k]].push(node);
}
}
}

for (let i = 0; i < node.children.length; i++) {
cacheIdRefs(node.children[i], idRefs, refAttrs);
}
}

/**
* Return all DOM nodes that use the nodes ID in the accessibility tree.
* @param {Element} node
* @returns {Element[]}
*/
function getAccessibleRefs(node) {
node = node.actualNode || node;
let root = getRootNode(node);
root = root.documentElement || root; // account for shadow roots

let idRefsByRoot = cache.get('idRefsByRoot');
if (!idRefsByRoot) {
idRefsByRoot = new WeakMap();
cache.set('idRefsByRoot', idRefsByRoot);
}

let idRefs = idRefsByRoot.get(root);
if (!idRefs) {
idRefs = {};
idRefsByRoot.set(root, idRefs);

const refAttrs = Object.keys(standards.ariaAttrs).filter(attr => {
const { type } = standards.ariaAttrs[attr];
return idRefsRegex.test(type);
});

cacheIdRefs(root, idRefs, refAttrs);
}

return idRefs[node.id] || [];
}

export default getAccessibleRefs;
2 changes: 0 additions & 2 deletions lib/commons/aria/implicit-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import lookupTable from './lookup-table';
* @return {Mixed} Either an Array of CSS selectors or `null` if there are none
*/
function implicitNodes(role) {
'use strict';

let implicit = null;
const roles = lookupTable.role[role];

Expand Down
1 change: 1 addition & 0 deletions lib/commons/aria/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export { default as allowedAttr } from './allowed-attr';
export { default as arialabelText } from './arialabel-text';
export { default as arialabelledbyText } from './arialabelledby-text';
export { default as getAccessibleRefs } from './get-accessible-refs';
export { default as getElementUnallowedRoles } from './get-element-unallowed-roles';
export { default as getExplicitRole } from './get-explicit-role';
export { default as getOwnedVirtual } from './get-owned-virtual';
Expand Down
57 changes: 2 additions & 55 deletions lib/commons/aria/is-accessible-ref.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,12 @@
import standards from '../../standards';
import getRootNode from '../dom/get-root-node';
import cache from '../../core/base/cache';
import { tokenList } from '../../core/utils';

const idRefsRegex = /^idrefs?$/;

function cacheIdRefs(node, refAttrs) {
if (node.hasAttribute) {
const idRefs = cache.get('idRefs');

if (node.nodeName.toUpperCase() === 'LABEL' && node.hasAttribute('for')) {
idRefs[node.getAttribute('for')] = true;
}

for (let i = 0; i < refAttrs.length; ++i) {
const attr = refAttrs[i];

if (!node.hasAttribute(attr)) {
continue;
}

const attrValue = node.getAttribute(attr);

const tokens = tokenList(attrValue);

for (let k = 0; k < tokens.length; ++k) {
idRefs[tokens[k]] = true;
}
}
}

for (let i = 0; i < node.children.length; i++) {
cacheIdRefs(node.children[i], refAttrs);
}
}
import getAccessibleRefs from './get-accessible-refs';

/**
* Check that a DOM node is a reference in the accessibility tree
* @param {Element} node
* @returns {Boolean}
*/
function isAccessibleRef(node) {
node = node.actualNode || node;
let root = getRootNode(node);
root = root.documentElement || root; // account for shadow roots
const id = node.id;

// because axe.commons is not available in axe.utils, we can't do
// this caching when we build up the virtual tree
if (!cache.get('idRefs')) {
cache.set('idRefs', {});
// Get all idref(s) attributes on the lookup table
const refAttrs = Object.keys(standards.ariaAttrs).filter(attr => {
const { type } = standards.ariaAttrs[attr];
return idRefsRegex.test(type);
});

cacheIdRefs(root, refAttrs);
}

return cache.get('idRefs')[id] === true;
return !!getAccessibleRefs(node).length;
}

export default isAccessibleRef;
2 changes: 1 addition & 1 deletion lib/commons/aria/label-virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function labelVirtual(virtualNode) {
// aria-label
candidate = virtualNode.attr('aria-label');
if (candidate) {
candidate = sanitize(candidate).trim();
candidate = sanitize(candidate);
if (candidate) {
return candidate;
}
Expand Down
1 change: 0 additions & 1 deletion lib/commons/aria/validate-attr-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { tokenList } from '../../core/utils';
* @return {Boolean}
*/
function validateAttrValue(node, attr) {
'use strict';
let matches;
let list;
const value = node.getAttribute(attr);
Expand Down
2 changes: 0 additions & 2 deletions lib/commons/dom/get-element-coordinates.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import getScrollOffset from './get-scroll-offset';
* @property {Number} height The height of the element
*/
function getElementCoordinates(element) {
'use strict';

var scrollOffset = getScrollOffset(document),
xOffset = scrollOffset.left,
yOffset = scrollOffset.top,
Expand Down
2 changes: 0 additions & 2 deletions lib/commons/dom/get-scroll-offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @return {Object} Contains the attributes `x` and `y` which contain the scroll offsets
*/
function getScrollOffset(element) {
'use strict';

if (!element.nodeType && element.document) {
element = element.document;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/commons/dom/get-viewport-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @return {Object} Object with the `width` and `height` of the viewport
*/
function getViewportSize(win) {
'use strict';

const doc = win.document;
const docElement = doc.documentElement;

Expand Down
1 change: 0 additions & 1 deletion lib/commons/dom/is-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* @return {Boolean}
*/
function isNode(element) {
'use strict';
return element instanceof window.Node;
}

Expand Down
2 changes: 0 additions & 2 deletions lib/commons/dom/is-visible.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ const clipPathRegex = /(\w+)\((\d+)/;
* @return {Boolean}
*/
function isClipped(style) {
'use strict';

const matchesClip = style.getPropertyValue('clip').match(clipRegex);
const matchesClipPath = style
.getPropertyValue('clip-path')
Expand Down
5 changes: 4 additions & 1 deletion lib/commons/text/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
* @return {String} Sanitized string
*/
function sanitize(str) {
'use strict';
if (!str) {
return '';
}

return str
.replace(/\r\n/g, '\n')
.replace(/\u00A0/g, ' ')
Expand Down
1 change: 0 additions & 1 deletion lib/core/base/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ Check.prototype.enabled = true;
* @param {Function} callback Function to fire when check is complete
*/
Check.prototype.run = function(node, options, context, resolve, reject) {
'use strict';
options = options || {};
const enabled = options.hasOwnProperty('enabled')
? options.enabled
Expand Down
28 changes: 5 additions & 23 deletions lib/core/imports/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
// @deprecated (axios)
import axios from 'axios';
import { CssSelectorParser } from 'css-selector-parser';
import doT from '@deque/dot';
import emojiRegexText from 'emoji-regex';
import memoize from 'memoizee';

import Promise from 'core-js-pure/features/promise';
import Uint32Array from 'core-js-pure/features/typed-array/uint32-array';
import WeakMap from 'core-js-pure/es/weak-map';
import es6promise from 'es6-promise';
import { Uint32Array } from 'typedarray';
import 'weakmap-polyfill';

/**
* Polyfill `WeakMap`
* Reference https://github.com/zloirock/core-js/
*/
if (!('WeakMap' in window)) {
window.WeakMap = WeakMap;
}

/**
* Polyfill `Promise`
* Reference https://github.com/zloirock/core-js/
*/
if (!('Promise' in window)) {
window.Promise = Promise;
es6promise.polyfill();
}

/**
* Polyfill required TypedArray and functions
* Reference https://github.com/zloirock/core-js/
*/
if (!('Uint32Array' in window)) {
window.Uint32Array = Uint32Array;
}
Expand All @@ -54,4 +36,4 @@ if (window.Uint32Array) {
* @namespace imports
* @memberof axe
*/
export { axios, CssSelectorParser, doT, emojiRegexText, memoize };
export { CssSelectorParser, doT, emojiRegexText, memoize };
1 change: 0 additions & 1 deletion lib/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ axe.version = '<%= pkg.version %>';
if (typeof define === 'function' && define.amd) {
// Explicitly naming the module to avoid mismatched anonymous define() modules when injected in a page
define('axe-core', [], function() {
'use strict';
return axe;
});
}
Expand Down
1 change: 0 additions & 1 deletion lib/core/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Logs a message to the developer console (if it exists and is active).
*/
function log() {
'use strict';
if (typeof console === 'object' && console.log) {
// IE does not support console.log.apply
Function.prototype.apply.call(console.log, console, arguments);
Expand Down
Loading

0 comments on commit 7da2c51

Please sign in to comment.