-
Notifications
You must be signed in to change notification settings - Fork 793
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2654 from dequelabs/release-4.1.1
chore: Release 4.1.1
- Loading branch information
Showing
45 changed files
with
264 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.