Skip to content
This repository was archived by the owner on Dec 7, 2022. It is now read-only.

Commit 33609ef

Browse files
committed
* 'master' of https://github.com/GoogleChrome/accessibility-developer-tools: fix: `axs.utils.getAriaIdReferrers` can return null for missing referrers which breaks `roleTooltipRequiresDescribedby` (#258) Make the npm module requireable (#298)
2 parents aecb168 + b64579d commit 33609ef

5 files changed

Lines changed: 24 additions & 3 deletions

File tree

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = function(grunt) {
8181
options: {
8282
configFile: '.eslintrc'
8383
},
84-
target: ['./src/js/', './src/audits/']
84+
target: ['./src/js/', './src/audits/', './Gruntfile.js', './main.js']
8585
},
8686

8787
prompt: {

main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This exposes the ./dist Javascript file for node libraries.
2+
// It also unwraps the main axs package so Audit and other objects are exposed
3+
// directly in the node library
4+
5+
var library = require('./dist/js/axs_testing'); // eslint-disable-line no-undef
6+
7+
module.exports = library.axs; // eslint-disable-line no-undef

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"url": "https://github.com/GoogleChrome/accessibility-developer-tools/issues"
3030
},
3131
"homepage": "https://github.com/GoogleChrome/accessibility-developer-tools",
32-
"main": "src/js/Audit.js",
32+
"main": "main.js",
3333
"directories": {
3434
"test": "test"
3535
},

src/js/AccessibilityUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ axs.utils.getQuerySelectorText = function(obj) {
10121012
* single ID reference.
10131013
* @param {Element} element a potential referent.
10141014
* @param {string=} opt_attributeName Name of an ARIA attribute to limit the results to, e.g. 'aria-owns'.
1015-
* @return {NodeList} The elements that refer to this element.
1015+
* @return {NodeList} The elements that refer to this element or null.
10161016
*/
10171017
axs.utils.getAriaIdReferrers = function(element, opt_attributeName) {
10181018
var propertyToSelector = function(propertyKey) {

test/audits/role-tooltip-requires-described-by-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,17 @@ test('a tooltip without an ID doesn\'t cause an exception', function() {
9191
ok(false, 'Running roleTooltipRequiresDescribedby threw an exception: ' + e.message);
9292
}
9393
});
94+
95+
test('role tooltip with a corresponding describedby of a missing element id should fail', function() {
96+
var fixture = document.getElementById('qunit-fixture');
97+
var tooltip = document.createElement('div');
98+
var trigger = document.createElement('div');
99+
fixture.appendChild(tooltip);
100+
fixture.appendChild(trigger);
101+
tooltip.setAttribute('role', 'tooltip');
102+
trigger.setAttribute('aria-describedby', 'tooltip1');
103+
deepEqual(
104+
axs.AuditRules.getRule('roleTooltipRequiresDescribedby').run({ scope: fixture }),
105+
{ elements: [tooltip], result: axs.constants.AuditResult.FAIL }
106+
);
107+
});

0 commit comments

Comments
 (0)