diff --git a/lib/checks/lists/dlitem.js b/lib/checks/lists/dlitem.js
index 96ec9e65b1..80a6608fc7 100644
--- a/lib/checks/lists/dlitem.js
+++ b/lib/checks/lists/dlitem.js
@@ -1,2 +1,2 @@
-return node.parentNode.tagName === 'DL';
-
+var parent = axe.commons.dom.getComposedParent(node);
+return parent.nodeName.toUpperCase() === 'DL';
diff --git a/lib/checks/lists/has-listitem.js b/lib/checks/lists/has-listitem.js
index d38f7bd805..05aff66304 100644
--- a/lib/checks/lists/has-listitem.js
+++ b/lib/checks/lists/has-listitem.js
@@ -1,9 +1,2 @@
-var children = node.children;
-if (children.length === 0) { return true; }
-
-for (var i = 0; i < children.length; i++) {
- if (children[i].nodeName.toUpperCase() === 'LI') { return false; }
-}
-
-return true;
-
+return virtualNode.children.every(({ actualNode }) =>
+ actualNode.nodeName.toUpperCase() !== 'LI');
diff --git a/lib/checks/lists/listitem.js b/lib/checks/lists/listitem.js
index 16e396b878..1a7abcb40d 100644
--- a/lib/checks/lists/listitem.js
+++ b/lib/checks/lists/listitem.js
@@ -1,6 +1,4 @@
-
-if (['UL', 'OL'].indexOf(node.parentNode.nodeName.toUpperCase()) !== -1) {
- return true;
-}
-
-return node.parentNode.getAttribute('role') === 'list';
+var parent = axe.commons.dom.getComposedParent(node);
+return (['UL', 'OL'].includes(parent.nodeName.toUpperCase()) ||
+ (parent.getAttribute('role') || '').toLowerCase() === 'list');
+
\ No newline at end of file
diff --git a/lib/checks/lists/only-dlitems.js b/lib/checks/lists/only-dlitems.js
index a003f8dbee..ff3a20d62d 100644
--- a/lib/checks/lists/only-dlitems.js
+++ b/lib/checks/lists/only-dlitems.js
@@ -1,19 +1,16 @@
-var child,
- nodeName,
- bad = [],
- children = node.childNodes,
+var bad = [],
permitted = ['STYLE', 'META', 'LINK', 'MAP', 'AREA', 'SCRIPT', 'DATALIST', 'TEMPLATE'],
hasNonEmptyTextNode = false;
-for (var i = 0; i < children.length; i++) {
- child = children[i];
- var nodeName = child.nodeName.toUpperCase();
- if (child.nodeType === 1 && nodeName !== 'DT' && nodeName !== 'DD' && permitted.indexOf(nodeName) === -1) {
- bad.push(child);
- } else if (child.nodeType === 3 && child.nodeValue.trim() !== '') {
+virtualNode.children.forEach(({ actualNode }) => {
+ var nodeName = actualNode.nodeName.toUpperCase();
+ if (actualNode.nodeType === 1 && nodeName !== 'DT' && nodeName !== 'DD' && permitted.indexOf(nodeName) === -1) {
+ bad.push(actualNode);
+ } else if (actualNode.nodeType === 3 && actualNode.nodeValue.trim() !== '') {
hasNonEmptyTextNode = true;
}
-}
+});
+
if (bad.length) {
this.relatedNodes(bad);
}
diff --git a/lib/checks/lists/only-listitems.js b/lib/checks/lists/only-listitems.js
index 547fe79652..bdb53064e5 100644
--- a/lib/checks/lists/only-listitems.js
+++ b/lib/checks/lists/only-listitems.js
@@ -1,19 +1,16 @@
-var child,
- nodeName,
- bad = [],
- children = node.childNodes,
+var bad = [],
permitted = ['STYLE', 'META', 'LINK', 'MAP', 'AREA', 'SCRIPT', 'DATALIST', 'TEMPLATE'],
hasNonEmptyTextNode = false;
-for (var i = 0; i < children.length; i++) {
- child = children[i];
- nodeName = child.nodeName.toUpperCase();
- if (child.nodeType === 1 && nodeName !== 'LI' && permitted.indexOf(nodeName) === -1) {
- bad.push(child);
- } else if (child.nodeType === 3 && child.nodeValue.trim() !== '') {
+virtualNode.children.forEach(({ actualNode }) => {
+ var nodeName = actualNode.nodeName.toUpperCase();
+ if (actualNode.nodeType === 1 && nodeName !== 'LI' && permitted.indexOf(nodeName) === -1) {
+ bad.push(actualNode);
+ } else if (actualNode.nodeType === 3 && actualNode.nodeValue.trim() !== '') {
hasNonEmptyTextNode = true;
}
-}
+});
+
if (bad.length) {
this.relatedNodes(bad);
}
diff --git a/lib/checks/lists/structured-dlitems.js b/lib/checks/lists/structured-dlitems.js
index b8578dffb1..7654da061d 100644
--- a/lib/checks/lists/structured-dlitems.js
+++ b/lib/checks/lists/structured-dlitems.js
@@ -1,9 +1,9 @@
-var children = node.children;
+var children = virtualNode.children;
if ( !children || !children.length) { return false; }
var hasDt = false, hasDd = false, nodeName;
for (var i = 0; i < children.length; i++) {
- nodeName = children[i].nodeName.toUpperCase();
+ nodeName = children[i].actualNode.nodeName.toUpperCase();
if (nodeName === 'DT') { hasDt = true; }
if (hasDt && nodeName === 'DD') { return false; }
if (nodeName === 'DD') { hasDd = true; }
diff --git a/lib/commons/dom/get-composed-parent.js b/lib/commons/dom/get-composed-parent.js
index c5cfc74339..fdec0a4b18 100644
--- a/lib/commons/dom/get-composed-parent.js
+++ b/lib/commons/dom/get-composed-parent.js
@@ -6,7 +6,10 @@
*/
dom.getComposedParent = function getComposedParent (element) {
if (element.assignedSlot) {
- return element.assignedSlot; // content of a shadow DOM slot
+ // NOTE: If the display of a slot element isn't 'contents',
+ // the slot shouldn't be ignored. Chrome does not support this (yet) so,
+ // we'll skip this part for now.
+ return getComposedParent(element.assignedSlot); // content of a shadow DOM slot
} else if (element.parentNode) {
var parentNode = element.parentNode;
if (parentNode.nodeType === 1) {
diff --git a/test/checks/lists/dlitem.js b/test/checks/lists/dlitem.js
index f8d50778c8..827e6a6405 100644
--- a/test/checks/lists/dlitem.js
+++ b/test/checks/lists/dlitem.js
@@ -2,26 +2,42 @@ describe('dlitem', function () {
'use strict';
var fixture = document.getElementById('fixture');
+ var checkSetup = axe.testUtils.checkSetup;
+ var shadowSupport = axe.testUtils.shadowSupport;
afterEach(function () {
fixture.innerHTML = '';
});
it('should pass if the dlitem has a parent
', function () {
- fixture.innerHTML = '
My list item
';
- var node = fixture.querySelector('#target');
+ var checkArgs = checkSetup('
My list item
');
- assert.isTrue(checks.dlitem.evaluate(node));
+ assert.isTrue(checks.dlitem.evaluate.apply(null, checkArgs));
+ });
+ it('should fail if the dlitem has an incorrect parent', function () {
+ var checkArgs = checkSetup('');
+ assert.isFalse(checks.dlitem.evaluate.apply(null, checkArgs));
});
- it('should fail if the dlitem has an incorrect parent', function () {
- fixture.innerHTML = '';
- var node = fixture.querySelector('#target');
+ (shadowSupport ? it : xit)('should return true in a shadow DOM pass', function () {
+ var node = document.createElement('div');
+ node.innerHTML = '
';
+ var checkArgs = checkSetup(node, 'dt');
+ assert.isFalse(checks.dlitem.evaluate.apply(null, checkArgs));
});
});
diff --git a/test/checks/lists/has-listitem.js b/test/checks/lists/has-listitem.js
index 083e2f68f9..87ca1f5865 100644
--- a/test/checks/lists/has-listitem.js
+++ b/test/checks/lists/has-listitem.js
@@ -2,45 +2,55 @@ describe('has-listitem', function () {
'use strict';
var fixture = document.getElementById('fixture');
+ var checkSetup = axe.testUtils.checkSetup;
+ var shadowSupport = axe.testUtils.shadowSupport;
afterEach(function () {
fixture.innerHTML = '';
});
it('should return true if the list has no contents', function () {
- fixture.innerHTML = '';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['has-listitem'].evaluate(node));
-
+ var checkArgs = checkSetup('');
+ assert.isTrue(checks['has-listitem'].evaluate.apply(null, checkArgs));
});
it('should return true if the list has non-li contents with li children', function () {
- fixture.innerHTML = '
Not a list
item
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['has-listitem'].evaluate(node));
-
+ var checkArgs = checkSetup('
Not a list
item
');
+ assert.isTrue(checks['has-listitem'].evaluate.apply(null, checkArgs));
});
it('should return true if the list has non-li contents', function () {
- fixture.innerHTML = '
Not a list
';
- var node = fixture.querySelector('#target');
+ var checkArgs = checkSetup('
Not a list
');
- assert.isTrue(checks['has-listitem'].evaluate(node));
+ assert.isTrue(checks['has-listitem'].evaluate.apply(null, checkArgs));
+ });
+ it('should return false if the list has at least one li', function () {
+ var checkArgs = checkSetup('
A list
Not a list
');
+ assert.isFalse(checks['has-listitem'].evaluate.apply(null, checkArgs));
});
- it('should return false if the list has at least one li', function () {
- fixture.innerHTML = '
A list
Not a list
';
- var node = fixture.querySelector('#target');
+ (shadowSupport ? it : xit)('should return true in a shadow DOM pass', function () {
+ var node = document.createElement('div');
+ node.innerHTML = '
';
+ var checkArgs = checkSetup(node, 'ul');
+ assert.isTrue(checks['has-listitem'].evaluate.apply(null, checkArgs));
});
});
diff --git a/test/checks/lists/listitem.js b/test/checks/lists/listitem.js
index 1c094a5eaa..179a631cd6 100644
--- a/test/checks/lists/listitem.js
+++ b/test/checks/lists/listitem.js
@@ -2,40 +2,54 @@ describe('listitem', function () {
'use strict';
var fixture = document.getElementById('fixture');
+ var checkSetup = axe.testUtils.checkSetup;
+ var shadowSupport = axe.testUtils.shadowSupport;
afterEach(function () {
fixture.innerHTML = '';
});
it('should pass if the listitem has a parent ', function () {
- fixture.innerHTML = '
My list item
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks.listitem.evaluate(node));
+ var checkArgs = checkSetup('
My list item
');
+ assert.isTrue(checks.listitem.evaluate.apply(null, checkArgs));
});
it('should pass if the listitem has a parent
', function () {
- fixture.innerHTML = '
My list item
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks.listitem.evaluate(node));
+ var checkArgs = checkSetup('
My list item
');
+ assert.isTrue(checks.listitem.evaluate.apply(null, checkArgs));
});
it('should pass if the listitem has a parent role=list', function () {
- fixture.innerHTML = '
My list item
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks.listitem.evaluate(node));
+ var checkArgs = checkSetup('
My list item
');
+ assert.isTrue(checks.listitem.evaluate.apply(null, checkArgs));
});
it('should fail if the listitem has an incorrect parent', function () {
- fixture.innerHTML = '
My list item
';
- var node = fixture.querySelector('#target');
+ var checkArgs = checkSetup('
My list item
');
+
+ assert.isFalse(checks.listitem.evaluate.apply(null, checkArgs));
+ });
+
+ (shadowSupport ? it : xit)('should return true in a shadow DOM pass', function () {
+ var node = document.createElement('div');
+ node.innerHTML = '
';
+ var checkArgs = checkSetup(node, 'li');
+ assert.isFalse(checks.listitem.evaluate.apply(null, checkArgs));
});
});
diff --git a/test/checks/lists/only-dlitems.js b/test/checks/lists/only-dlitems.js
index 6bfae020fa..efca12bc64 100644
--- a/test/checks/lists/only-dlitems.js
+++ b/test/checks/lists/only-dlitems.js
@@ -2,6 +2,8 @@ describe('only-dlitems', function () {
'use strict';
var fixture = document.getElementById('fixture');
+ var checkSetup = axe.testUtils.checkSetup;
+ var shadowSupport = axe.testUtils.shadowSupport;
var checkContext = {
_relatedNodes: [],
@@ -16,115 +18,109 @@ describe('only-dlitems', function () {
});
it('should return false if the list has no contents', function () {
- fixture.innerHTML = '
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
');
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return true if the list has non-dd/dt contents', function () {
- fixture.innerHTML = '
Not a list
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['only-dlitems'].evaluate.call(checkContext, node));
- assert.deepEqual(checkContext._relatedNodes, [node.querySelector('p')]);
-
+ var checkArgs = checkSetup('
Not a list
');
+ assert.isTrue(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
+ assert.deepEqual(checkContext._relatedNodes, [fixture.querySelector('p')]);
});
it('should return false if the list has only a dd', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
A list
');
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if the list has only a dt', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
A list
');
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if the list has dt and dd with child content', function () {
- fixture.innerHTML = '
An item
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
An item
A list
');
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if the list has dt and dd', function () {
- fixture.innerHTML = '
An item
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
An item
A list
');
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if the list has dt, dd and a comment', function () {
- fixture.innerHTML = '
An item
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
An item
A list
');
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return true if the list has a dt and dd with other content', function () {
- fixture.innerHTML = '
Item one
Description
Not a list
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['only-dlitems'].evaluate.call(checkContext, node));
- assert.deepEqual(checkContext._relatedNodes, [node.querySelector('p')]);
-
+ var checkArgs = checkSetup('
Item one
Description
Not a list
');
+ assert.isTrue(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
+ assert.deepEqual(checkContext._relatedNodes, [fixture.querySelector('p')]);
});
it('should return true if the list has a textNode as a child', function () {
- fixture.innerHTML = '
hi
hello
hi
';
- var node = fixture.querySelector('#target');
+ var checkArgs = checkSetup('
hi
hello
hi
');
- assert.isTrue(checks['only-dlitems'].evaluate.call(checkContext, node));
+ assert.isTrue(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
assert.deepEqual(checkContext._relatedNodes, []);
});
-
it('should return false if is used along side dt', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-dlitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if is used along side dt', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-dlitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-dlitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-dlitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if is used along side dt', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-dlitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
+ });
+
+ (shadowSupport ? it : xit)('should return false in a shadow DOM pass', function () {
+ var node = document.createElement('div');
+ node.innerHTML = '
';
+
+ var checkArgs = checkSetup(node, 'dl');
+ assert.isTrue(checks['only-dlitems'].evaluate.apply(checkContext, checkArgs));
});
});
diff --git a/test/checks/lists/only-listitems.js b/test/checks/lists/only-listitems.js
index 066ae53d03..4be9a4e8b4 100644
--- a/test/checks/lists/only-listitems.js
+++ b/test/checks/lists/only-listitems.js
@@ -2,6 +2,8 @@ describe('only-listitems', function () {
'use strict';
var fixture = document.getElementById('fixture');
+ var checkSetup = axe.testUtils.checkSetup;
+ var shadowSupport = axe.testUtils.shadowSupport;
var checkContext = {
_relatedNodes: [],
@@ -16,103 +18,103 @@ describe('only-listitems', function () {
});
it('should return false if the list has no contents', function () {
- fixture.innerHTML = '';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-listitems'].evaluate(node));
-
+ var checkArgs = checkSetup('');
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if the list has whitespace', function () {
- fixture.innerHTML = '
Item
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-listitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
Item
');
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if the list has non-li comments', function () {
- fixture.innerHTML = '
Item
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-listitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
Item
');
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return true if the list has non-li text contents', function () {
- fixture.innerHTML = '
Item
Not an item';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['only-listitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
Item
Not an item');
+ assert.isTrue(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return true if the list has non-li contents', function () {
- fixture.innerHTML = '
Not a list
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['only-listitems'].evaluate.call(checkContext, node));
- assert.deepEqual(checkContext._relatedNodes, [node.querySelector('p')]);
-
+ var checkArgs = checkSetup('
Not a list
');
+ assert.isTrue(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
+ assert.deepEqual(checkContext._relatedNodes, [fixture.querySelector('p')]);
});
it('should return false if the list has only an li with child content', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['only-listitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
A list
');
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if the list has only an li', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
+ var checkArgs = checkSetup('
A list
');
- assert.isFalse(checks['only-listitems'].evaluate(node));
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return true if the list has an li with other content', function () {
- fixture.innerHTML = '
A list
Not a list
';
- var node = fixture.querySelector('#target');
+ var checkArgs = checkSetup('
A list
Not a list
');
- assert.isTrue(checks['only-listitems'].evaluate.call(checkContext, node));
- assert.deepEqual(checkContext._relatedNodes, [node.querySelector('p')]);
+ assert.isTrue(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
+ assert.deepEqual(checkContext._relatedNodes, [fixture.querySelector('p')]);
});
it('should return false if is used along side li', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-listitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if is used along side li', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-listitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-listitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-listitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
});
it('should return false if is used along side li', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
- assert.isFalse(checks['only-listitems'].evaluate.call(checkContext, node));
+ var checkArgs = checkSetup('
A list
');
+
+ assert.isFalse(checks['only-listitems'].evaluate.apply(checkContext, checkArgs));
+ });
+
+ (shadowSupport ? it : xit)('should return false in a shadow DOM pass', function () {
+ var node = document.createElement('div');
+ node.innerHTML = '
';
+
+ var checkArgs = checkSetup(node, 'ul');
+ assert.isTrue(checks['only-listitems'].evaluate.apply(null, checkArgs));
});
});
diff --git a/test/checks/lists/structured-dlitems.js b/test/checks/lists/structured-dlitems.js
index e95fb22265..87dac603cd 100644
--- a/test/checks/lists/structured-dlitems.js
+++ b/test/checks/lists/structured-dlitems.js
@@ -2,72 +2,71 @@ describe('structured-dlitems', function () {
'use strict';
var fixture = document.getElementById('fixture');
+ var checkSetup = axe.testUtils.checkSetup;
+ var shadowSupport = axe.testUtils.shadowSupport;
afterEach(function () {
fixture.innerHTML = '';
});
it('should return false if the list has no contents', function () {
- fixture.innerHTML = '
';
- var node = fixture.querySelector('#target');
-
- assert.isFalse(checks['structured-dlitems'].evaluate(node));
-
-
+ var checkArgs = checkSetup('
');
+ assert.isFalse(checks['structured-dlitems'].evaluate.apply(null, checkArgs));
});
it('should return true if the list has only a dd', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['structured-dlitems'].evaluate(node));
-
-
+ var checkArgs = checkSetup('
A list
');
+ assert.isTrue(checks['structured-dlitems'].evaluate.apply(null, checkArgs));
});
it('should return true if the list has only a dt', function () {
- fixture.innerHTML = '
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['structured-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
A list
');
+ assert.isTrue(checks['structured-dlitems'].evaluate.apply(null, checkArgs));
});
it('should return true if the list has dt and dd in the incorrect order', function () {
- fixture.innerHTML = '
A list
An item
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['structured-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
A list
An item
');
+ assert.isTrue(checks['structured-dlitems'].evaluate.apply(null, checkArgs));
});
it('should return true if the list has dt and dd in the correct order as non-child descendants', function () {
- fixture.innerHTML = '
An item
A list
';
- var node = fixture.querySelector('#target');
-
- assert.isTrue(checks['structured-dlitems'].evaluate(node));
-
+ var checkArgs = checkSetup('
An item
A list
');
+ assert.isTrue(checks['structured-dlitems'].evaluate.apply(null, checkArgs));
});
it('should return false if the list has dt and dd in the correct order', function () {
- fixture.innerHTML = '
An item
A list
';
- var node = fixture.querySelector('#target');
+ var checkArgs = checkSetup('
An item
A list
');
- assert.isFalse(checks['structured-dlitems'].evaluate(node));
+ assert.isFalse(checks['structured-dlitems'].evaluate.apply(null, checkArgs));
+ });
+ it('should return false if the list has a correctly-ordered dt and dd with other content', function () {
+ var checkArgs = checkSetup('
Stuff
Item one
Description
Not a list
');
+ assert.isFalse(checks['structured-dlitems'].evaluate.apply(null, checkArgs));
});
- it('should return false if the list has a correctly-ordered dt and dd with other content', function () {
- fixture.innerHTML = '
Stuff
Item one
Description
Not a list
';
- var node = fixture.querySelector('#target');
+ (shadowSupport ? it : xit)('should return false in a shadow DOM pass', function () {
+ var node = document.createElement('div');
+ node.innerHTML = '