diff --git a/lib/checks/lists/listitem.js b/lib/checks/lists/listitem.js index ed1f25d685..981b6d958d 100644 --- a/lib/checks/lists/listitem.js +++ b/lib/checks/lists/listitem.js @@ -7,7 +7,7 @@ if (!parent) { const parentTagName = parent.nodeName.toUpperCase(); const parentRole = (parent.getAttribute('role') || '').toLowerCase(); -if (parentRole === 'list') { +if (['presentation', 'none', 'list'].includes(parentRole)) { return true; } diff --git a/test/checks/lists/listitem.js b/test/checks/lists/listitem.js index 1b14295f57..5f555045ea 100644 --- a/test/checks/lists/listitem.js +++ b/test/checks/lists/listitem.js @@ -29,6 +29,20 @@ describe('listitem', function() { assert.isTrue(checks.listitem.evaluate.call(checkContext, target)); }); + it('should pass if the listitem has a parent role=none', function() { + fixture.innerHTML = + ''; + var target = fixture.querySelector('#target'); + assert.isTrue(checks.listitem.evaluate.call(checkContext, target)); + }); + + it('should pass if the listitem has a parent role=presentation', function() { + fixture.innerHTML = + ''; + var target = fixture.querySelector('#target'); + assert.isTrue(checks.listitem.evaluate.call(checkContext, target)); + }); + it('should fail if the listitem has an incorrect parent', function() { fixture.innerHTML = '
  • My list item
  • '; var target = fixture.querySelector('#target'); diff --git a/test/integration/rules/listitem/listitem.html b/test/integration/rules/listitem/listitem.html index 07296e5ead..5348f92f72 100644 --- a/test/integration/rules/listitem/listitem.html +++ b/test/integration/rules/listitem/listitem.html @@ -7,6 +7,12 @@
    1. Also belongs to a list.
    + + diff --git a/test/integration/rules/listitem/listitem.json b/test/integration/rules/listitem/listitem.json index 036d4dc42e..b32ddf8d88 100644 --- a/test/integration/rules/listitem/listitem.json +++ b/test/integration/rules/listitem/listitem.json @@ -2,5 +2,5 @@ "description": "listitem test", "rule": "listitem", "violations": [["#uncontained"], ["#ulrolechanged"], ["#olrolechanged"]], - "passes": [["#contained"], ["#alsocontained"]] + "passes": [["#contained"], ["#alsocontained"], ["#presentation"], ["#none"]] }