Skip to content

Commit

Permalink
Fixed tests, ignoring ADT code from linter
Browse files Browse the repository at this point in the history
Summary:
Was rushing, and broke all the things :)

Test plan:
. npm test
. npm run lint

Auditors: michelle
  • Loading branch information
jdan committed Sep 27, 2015
1 parent ac5b62c commit dd28057
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
38 changes: 20 additions & 18 deletions plugins/shared/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function createWhitelist(ruleName) {
return config;
}

/*eslint-disable*/
// Patch collectMatchingElements to match
// https://github.com/GoogleChrome/accessibility-developer-tools/blob/0062f77258eb4eb8508dad3c92fd2df63c2381fc/src/js/AuditRule.js
//
Expand All @@ -41,8 +42,8 @@ function patchCollectMatchingElements() {
* @param {ShadowRoot=} opt_shadowRoot The nearest ShadowRoot ancestor, if any.
*/
$.axs.AuditRule.collectMatchingElements = function(node, matcher, collection,
opt_shadowRoot) {
if (node.nodeType == Node.ELEMENT_NODE)
opt_shadowRoot) {
if (node.nodeType == $.window.Node.ELEMENT_NODE)
var element = /** @type {Element} */ (node);

if (element && matcher.call(null, element))
Expand All @@ -57,10 +58,10 @@ function patchCollectMatchingElements() {
// code, be sure to run the tests in the browser before committing.
var shadowRoot = element.shadowRoot || element.webkitShadowRoot;
if (shadowRoot) {
axs.AuditRule.collectMatchingElements(shadowRoot,
matcher,
collection,
shadowRoot);
$.axs.AuditRule.collectMatchingElements(shadowRoot,
matcher,
collection,
shadowRoot);
return;
}
}
Expand All @@ -72,10 +73,10 @@ function patchCollectMatchingElements() {
var content = /** @type {HTMLContentElement} */ (element);
var distributedNodes = content.getDistributedNodes();
for (var i = 0; i < distributedNodes.length; i++) {
axs.AuditRule.collectMatchingElements(distributedNodes[i],
matcher,
collection,
opt_shadowRoot);
$.axs.AuditRule.collectMatchingElements(distributedNodes[i],
matcher,
collection,
opt_shadowRoot);
}
return;
}
Expand All @@ -89,10 +90,10 @@ function patchCollectMatchingElements() {
} else {
var distributedNodes = shadow.getDistributedNodes();
for (var i = 0; i < distributedNodes.length; i++) {
axs.AuditRule.collectMatchingElements(distributedNodes[i],
matcher,
collection,
opt_shadowRoot);
$.axs.AuditRule.collectMatchingElements(distributedNodes[i],
matcher,
collection,
opt_shadowRoot);
}
}
}
Expand All @@ -101,14 +102,15 @@ function patchCollectMatchingElements() {
// a <shadow> element recurse normally.
var child = node.firstChild;
while (child != null) {
axs.AuditRule.collectMatchingElements(child,
matcher,
collection,
opt_shadowRoot);
$.axs.AuditRule.collectMatchingElements(child,
matcher,
collection,
opt_shadowRoot);
child = child.nextSibling;
}
};
}
/*eslint-enable*/

// Audits for a single rule (by name) and returns the results for only that
// rule
Expand Down
3 changes: 3 additions & 0 deletions test/mock-dom/jquery-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ $.fn.expandedText = function() {

// Bind the global `axs` object from Accessibility Developer Tools to jQuery
$.axs = window.axs;

// Bind the global `window` object as well as a catch-all
$.window = window;

0 comments on commit dd28057

Please sign in to comment.