Skip to content

Commit

Permalink
fix: get tests all passing (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanb authored and WilcoFiers committed Jul 21, 2017
1 parent 70c72b4 commit 4874327
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Audit.prototype.run = function (context, options, resolve, reject) {
'use strict';
this.validateOptions(options);

axe._tree = axe.utils.getFlattenedTree(document.body); //cache the flattened tree
axe._tree = axe.utils.getFlattenedTree(document.documentElement); //cache the flattened tree
var q = axe.utils.queue();
this.rules.forEach(function (rule) {
if (axe.utils.ruleShouldRun(rule, context, options)) {
Expand Down
3 changes: 3 additions & 0 deletions lib/core/utils/flattened-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ axe.utils.getFlattenedTree = function (node, shadowId) {
axe.utils.getNodeFromTree = function (vNode, node) {
var found;

if (vNode.actualNode === node) {
return vNode;
}
vNode.children.forEach((candidate) => {
var retVal;

Expand Down
2 changes: 1 addition & 1 deletion test/checks/navigation/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('region', function () {
});

it('ignores native landmark elements with an overwriting role', function () {
var checkArgs = checkSetup('<div id="target"><header role="banner"></header><main role="none"></main></div>');
var checkArgs = checkSetup('<div id="target"><header role="heading" level="1"></header><main role="none">Content</main></div>');

assert.isFalse(checks.region.evaluate.apply(checkContext, checkArgs));
assert.lengthOf(checkContext._relatedNodes, 1);
Expand Down
2 changes: 1 addition & 1 deletion test/commons/dom/is-in-text-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('dom.isInTextBlock', function () {
assert.isFalse(axe.commons.dom.isInTextBlock(link));
});

(shadowSupport ? it : xit)('can reach outside a shadow tree', function () {
(shadowSupport.v1 ? it : xit)('can reach outside a shadow tree', function () {
var div = document.createElement('div');
div.innerHTML = 'Some paragraph with text <span></span> ';
var shadow = div.querySelector('span').attachShadow({ mode: 'open' });
Expand Down
6 changes: 6 additions & 0 deletions test/core/utils/flattened-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ if (shadowSupport.v1) {
assert.equal(node, vNode.actualNode);
assert.equal(vNode.actualNode.textContent, '1');
});
it('should find the virtual node if it is the very top of the tree', function () {
var virtualDOM = axe.utils.getFlattenedTree(fixture);
var vNode = axe.utils.getNodeFromTree(virtualDOM[0], virtualDOM[0].actualNode);
assert.isDefined(vNode);
assert.equal(virtualDOM[0].actualNode, vNode.actualNode);
});
});
}

Expand Down

0 comments on commit 4874327

Please sign in to comment.