From 50e7c23ae98e42fbc729baaa1500223af315a06b Mon Sep 17 00:00:00 2001 From: "Ava (Gaiety)" <165677673+gaiety-deque@users.noreply.github.com> Date: Mon, 17 Jun 2024 06:09:26 -0500 Subject: [PATCH] chore(test/rule-matches): var -> const & let (#4497) For `test/rule-matches` Smaller part of the full vision: https://github.com/dequelabs/axe-core/pull/4444 --- .../rule-matches/aria-allowed-attr-matches.js | 8 +- .../rule-matches/aria-allowed-role-matches.js | 12 +- test/rule-matches/aria-has-attr-matches.js | 12 +- .../rule-matches/aria-hidden-focus-matches.js | 20 +-- .../aria-required-children-matches.js | 10 +- .../aria-required-parent-matches.js | 10 +- test/rule-matches/autocomplete-matches.js | 40 ++--- test/rule-matches/color-contrast-matches.js | 140 +++++++++--------- test/rule-matches/data-table-matches.js | 12 +- .../duplicate-id-active-matches.js | 22 +-- .../rule-matches/duplicate-id-aria-matches.js | 22 +-- .../rule-matches/duplicate-id-misc-matches.js | 22 +-- .../frame-focusable-content-matches.js | 12 +- .../frame-title-has-text-matches.js | 10 +- .../has-implicit-chromium-role-matches.js | 14 +- test/rule-matches/heading-matches.js | 24 +-- test/rule-matches/html-namespace-matches.js | 30 ++-- test/rule-matches/html-xml-lang-mismatch.js | 18 +-- .../identical-links-same-purpose-matches.js | 48 +++--- .../inserted-into-focus-order-matches.js | 16 +- test/rule-matches/is-initiator-matches.js | 4 +- test/rule-matches/is-visible-matches.js | 6 +- .../label-content-name-mismatch-matches.js | 74 ++++----- test/rule-matches/label-matches.js | 16 +- .../rule-matches/landmark-has-body-context.js | 18 +-- test/rule-matches/landmark-unique-matches.js | 83 ++++++----- test/rule-matches/layout-table-matches.js | 14 +- .../nested-interactive-matches.js | 14 +- .../rule-matches/no-autoplay-audio-matches.js | 20 +-- test/rule-matches/no-empty-role-matches.js | 36 ++--- .../no-explicit-name-required-matches.js | 34 ++--- test/rule-matches/no-naming-method-matches.js | 50 +++---- test/rule-matches/no-negative-tabindex.js | 26 ++-- test/rule-matches/p-as-heading-matches.js | 18 +-- .../scrollable-region-focusable-matches.js | 88 +++++------ test/rule-matches/skip-link-matches.js | 4 +- test/rule-matches/svg-namespace-matches.js | 36 ++--- 37 files changed, 527 insertions(+), 516 deletions(-) diff --git a/test/rule-matches/aria-allowed-attr-matches.js b/test/rule-matches/aria-allowed-attr-matches.js index 5b7dfb33a6..e4177e0f78 100644 --- a/test/rule-matches/aria-allowed-attr-matches.js +++ b/test/rule-matches/aria-allowed-attr-matches.js @@ -1,8 +1,8 @@ describe('aria-allowed-attr-matches', function () { 'use strict'; - var queryFixture = axe.testUtils.queryFixture; - var rule; + const queryFixture = axe.testUtils.queryFixture; + let rule; beforeEach(function () { rule = axe.utils.getRule('aria-allowed-attr'); @@ -13,7 +13,7 @@ describe('aria-allowed-attr-matches', function () { }); it('should return true on elements that have aria attributes', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
' ); @@ -21,7 +21,7 @@ describe('aria-allowed-attr-matches', function () { }); it('should return false on elements that have no aria attributes', function () { - var vNode = queryFixture('
'); + const vNode = queryFixture('
'); assert.isFalse(rule.matches(null, vNode)); }); diff --git a/test/rule-matches/aria-allowed-role-matches.js b/test/rule-matches/aria-allowed-role-matches.js index 28992fde4c..14769d0d77 100644 --- a/test/rule-matches/aria-allowed-role-matches.js +++ b/test/rule-matches/aria-allowed-role-matches.js @@ -1,27 +1,29 @@ describe('aria-allowed-role-matches', function () { 'use strict'; - var queryFixture = axe.testUtils.queryFixture; - var rule; + const queryFixture = axe.testUtils.queryFixture; + let rule; beforeEach(function () { rule = axe.utils.getRule('aria-allowed-role'); }); it('return false (no matches) for a with a href to have any invalid role', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); assert.isFalse(rule.matches(null, vNode)); }); it('return true for input with redundant role', function () { - var vNode = queryFixture(''); + const vNode = queryFixture( + '' + ); assert.isTrue(rule.matches(null, vNode)); }); it('return true for element with valid role', function () { - var vNode = queryFixture('
    '); + const vNode = queryFixture('
      '); assert.isTrue(rule.matches(null, vNode)); }); }); diff --git a/test/rule-matches/aria-has-attr-matches.js b/test/rule-matches/aria-has-attr-matches.js index c3e0adbb52..a724a68a0a 100644 --- a/test/rule-matches/aria-has-attr-matches.js +++ b/test/rule-matches/aria-has-attr-matches.js @@ -1,9 +1,9 @@ describe('aria-has-attr-matches', function () { 'use strict'; - var queryFixture = axe.testUtils.queryFixture; - var fixtureSetup = axe.testUtils.fixtureSetup; - var rule; + const queryFixture = axe.testUtils.queryFixture; + const fixtureSetup = axe.testUtils.fixtureSetup; + let rule; beforeEach(function () { rule = axe.utils.getRule('aria-valid-attr-value'); @@ -14,16 +14,16 @@ describe('aria-has-attr-matches', function () { }); it('should return false if an element has no attributes', function () { - var vNode = fixtureSetup('
      '); + const vNode = fixtureSetup('
      '); assert.isFalse(rule.matches(null, vNode)); }); it('should return false if an element has no ARIA attributes', function () { - var vNode = queryFixture('
      '); + const vNode = queryFixture('
      '); assert.isFalse(rule.matches(null, vNode)); }); it('should return true if an element has ARIA attributes', function () { - var vNode = queryFixture('
      '); + const vNode = queryFixture('
      '); assert.isTrue(rule.matches(null, vNode)); }); }); diff --git a/test/rule-matches/aria-hidden-focus-matches.js b/test/rule-matches/aria-hidden-focus-matches.js index b770c88323..0a498004af 100644 --- a/test/rule-matches/aria-hidden-focus-matches.js +++ b/test/rule-matches/aria-hidden-focus-matches.js @@ -1,8 +1,8 @@ describe('aria-hidden-focus-matches', function () { 'use strict'; - var rule; - var queryFixture = axe.testUtils.queryFixture; + let rule; + const queryFixture = axe.testUtils.queryFixture; beforeEach(function () { rule = axe.utils.getRule('aria-hidden-focus'); @@ -13,24 +13,24 @@ describe('aria-hidden-focus-matches', function () { }); it('return true when there is no parent with aria-hidden', function () { - var vNode = queryFixture('
      ' + '
      '); - var actual = rule.matches(vNode.actualNode); + const vNode = queryFixture('
      ' + '
      '); + const actual = rule.matches(vNode.actualNode); assert.isTrue(actual); }); it('return false when has a parent element with aria-hidden', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode); + const actual = rule.matches(vNode.actualNode); assert.isFalse(actual); }); it('return false when has any parent element with aria-hidden', function () { - var vNode = queryFixture( + const vNode = queryFixture( ' `; - var target = fixture.querySelector('#target'); + const target = fixture.querySelector('#target'); axe.testUtils.flatTreeSetup(fixture); assert.isFalse(rule.matches(target, axe.utils.getNodeFromTree(target))); }); @@ -436,13 +436,13 @@ describe('color-contrast-matches', function () { fixture.innerHTML = '
      ' + '
      '; - var shadowRoot = document + const shadowRoot = document .getElementById('parent') .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = '
      Text
      '; - var shadowTarget = + const shadowTarget = fixture.firstChild.shadowRoot.querySelector('#shadowTarget'); axe.testUtils.flatTreeSetup(fixture); assert.isTrue( @@ -453,7 +453,7 @@ describe('color-contrast-matches', function () { it('should look at the correct root node when looking up an explicit label and disabled input', function () { fixture.innerHTML = '
      ' + '' + '
      '; - var shadowRoot = document + const shadowRoot = document .getElementById('parent') .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = @@ -462,7 +462,7 @@ describe('color-contrast-matches', function () { '' + ''; - var shadowLabel = + const shadowLabel = fixture.firstChild.shadowRoot.querySelector('#shadowLabel'); axe.testUtils.flatTreeSetup(fixture); assert.isFalse( @@ -473,7 +473,7 @@ describe('color-contrast-matches', function () { it('should look at the correct root node when looking up implicit label and disabled input', function () { fixture.innerHTML = '
      ' + '' + '
      '; - var shadowRoot = document + const shadowRoot = document .getElementById('parent') .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = @@ -481,7 +481,7 @@ describe('color-contrast-matches', function () { '' + ''; - var shadowLabel = + const shadowLabel = fixture.firstChild.shadowRoot.querySelector('#shadowLabel'); axe.testUtils.flatTreeSetup(fixture); assert.isFalse( @@ -492,7 +492,7 @@ describe('color-contrast-matches', function () { it("should look at the correct root node for a disabled control's label associated w/ aria-labelledby", function () { fixture.innerHTML = '
      ' + '' + '
      '; - var shadowRoot = document + const shadowRoot = document .getElementById('parent') .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = @@ -501,7 +501,7 @@ describe('color-contrast-matches', function () { '' + ''; - var shadowLabel = + const shadowLabel = fixture.firstChild.shadowRoot.querySelector('#shadowLabel'); axe.testUtils.flatTreeSetup(fixture); assert.isFalse( @@ -512,11 +512,11 @@ describe('color-contrast-matches', function () { it('should handle input/label spread across the shadow boundary', function () { fixture.innerHTML = ''; - var container = document.getElementById('firstChild'); - var shadowRoot = container.attachShadow({ mode: 'open' }); + const container = document.getElementById('firstChild'); + const shadowRoot = container.attachShadow({ mode: 'open' }); shadowRoot.innerHTML = ''; - var shadowTarget = container.shadowRoot.querySelector('#input'); + const shadowTarget = container.shadowRoot.querySelector('#input'); axe.testUtils.flatTreeSetup(fixture); assert.isFalse( rule.matches(shadowTarget, axe.utils.getNodeFromTree(shadowTarget)) @@ -529,14 +529,14 @@ describe('color-contrast-matches', function () { '
      ' + ''; - var shadowRoot = document + const shadowRoot = document .getElementById('firstChild') .attachShadow({ mode: 'open' }); shadowRoot.innerHTML = 'Some text' + '

      Other text

      '; - var firstChild = fixture.querySelector('#firstChild'); + const firstChild = fixture.querySelector('#firstChild'); axe.testUtils.flatTreeSetup(fixture); assert.isTrue( rule.matches(firstChild, axe.utils.getNodeFromTree(firstChild)) @@ -550,16 +550,16 @@ describe('color-contrast-matches', function () { ''; function createContentSlotted() { - var group = document.createElement('span'); + const group = document.createElement('span'); group.innerHTML = ''; return group; } - var slotted = fixture.querySelector('.slotted'); - var shadowRoot = slotted.attachShadow({ mode: 'open' }); + const slotted = fixture.querySelector('.slotted'); + const shadowRoot = slotted.attachShadow({ mode: 'open' }); shadowRoot.appendChild(createContentSlotted()); - var input = slotted.querySelector('input'); + const input = slotted.querySelector('input'); axe.testUtils.flatTreeSetup(fixture); assert.isTrue(rule.matches(input, axe.utils.getNodeFromTree(input))); }); diff --git a/test/rule-matches/data-table-matches.js b/test/rule-matches/data-table-matches.js index ab1e92523f..24e0fff16e 100644 --- a/test/rule-matches/data-table-matches.js +++ b/test/rule-matches/data-table-matches.js @@ -1,9 +1,9 @@ describe('data-table-matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var fixtureSetup = axe.testUtils.fixtureSetup; - var rule; + const fixture = document.getElementById('fixture'); + const fixtureSetup = axe.testUtils.fixtureSetup; + let rule; beforeEach(function () { rule = axe.utils.getRule('th-has-data-cells'); @@ -25,7 +25,7 @@ describe('data-table-matches', function () { '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -37,7 +37,7 @@ describe('data-table-matches', function () { '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -50,7 +50,7 @@ describe('data-table-matches', function () { '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'table')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); }); diff --git a/test/rule-matches/duplicate-id-active-matches.js b/test/rule-matches/duplicate-id-active-matches.js index 60bb45d3c6..f34db28c61 100644 --- a/test/rule-matches/duplicate-id-active-matches.js +++ b/test/rule-matches/duplicate-id-active-matches.js @@ -1,9 +1,9 @@ describe('duplicate-id-active matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var fixtureSetup = axe.testUtils.fixtureSetup; - var rule; + const fixture = document.getElementById('fixture'); + const fixtureSetup = axe.testUtils.fixtureSetup; + let rule; beforeEach(function () { rule = axe.utils.getRule('duplicate-id-active'); @@ -19,31 +19,31 @@ describe('duplicate-id-active matches', function () { it('returns false if the ID is of an inactive non-referenced element', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); it('returns false if the ID is of an inactive non-referenced element with a duplicate', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); it('returns true if the ID is of an active non-referenced element', function () { fixtureSetup(''); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); it('returns true if the ID is a duplicate of an active non-referenced element', function () { fixtureSetup('
      ' + ''); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); it('returns false if the ID is of an inactive ARIA referenced element', function () { fixtureSetup('
      ' + '
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -53,7 +53,7 @@ describe('duplicate-id-active matches', function () { '
      ' + '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -61,7 +61,7 @@ describe('duplicate-id-active matches', function () { fixtureSetup( '' + '
      ' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -71,7 +71,7 @@ describe('duplicate-id-active matches', function () { '
      ' + '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); }); diff --git a/test/rule-matches/duplicate-id-aria-matches.js b/test/rule-matches/duplicate-id-aria-matches.js index 2ebd3a0714..4ddf03f740 100644 --- a/test/rule-matches/duplicate-id-aria-matches.js +++ b/test/rule-matches/duplicate-id-aria-matches.js @@ -1,9 +1,9 @@ describe('duplicate-id-aria matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var fixtureSetup = axe.testUtils.fixtureSetup; - var rule; + const fixture = document.getElementById('fixture'); + const fixtureSetup = axe.testUtils.fixtureSetup; + let rule; beforeEach(function () { rule = axe.utils.getRule('duplicate-id-aria'); @@ -19,31 +19,31 @@ describe('duplicate-id-aria matches', function () { it('returns false if the ID is of an inactive non-referenced element', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); it('returns false if the ID is of an inactive non-referenced element with a duplicate', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); it('returns false if the ID is of an active non-referenced element', function () { fixtureSetup(''); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); it('returns false if the ID is a duplicate of an active non-referenced element', function () { fixtureSetup('
      ' + ''); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); it('returns true if the ID is of an inactive ARIA referenced element', function () { fixtureSetup('
      ' + '
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); @@ -53,7 +53,7 @@ describe('duplicate-id-aria matches', function () { '
      ' + '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); @@ -61,7 +61,7 @@ describe('duplicate-id-aria matches', function () { fixtureSetup( '' + '
      ' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); @@ -71,7 +71,7 @@ describe('duplicate-id-aria matches', function () { '
      ' + '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); }); diff --git a/test/rule-matches/duplicate-id-misc-matches.js b/test/rule-matches/duplicate-id-misc-matches.js index 77f2331b22..d44c94059b 100644 --- a/test/rule-matches/duplicate-id-misc-matches.js +++ b/test/rule-matches/duplicate-id-misc-matches.js @@ -1,9 +1,9 @@ describe('duplicate-id-misc matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var fixtureSetup = axe.testUtils.fixtureSetup; - var rule; + const fixture = document.getElementById('fixture'); + const fixtureSetup = axe.testUtils.fixtureSetup; + let rule; beforeEach(function () { rule = axe.utils.getRule('duplicate-id'); @@ -19,31 +19,31 @@ describe('duplicate-id-misc matches', function () { it('returns true if the ID is of an inactive non-referenced element', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); it('returns true if the ID is of an inactive non-referenced element with a duplicate', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); it('returns false if the ID is of an active non-referenced element', function () { fixtureSetup(''); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); it('returns false if the ID is a duplicate of an active non-referenced element', function () { fixtureSetup('
      ' + ''); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); it('returns false if the ID is of an inactive ARIA referenced element', function () { fixtureSetup('
      ' + '
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'div[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -53,7 +53,7 @@ describe('duplicate-id-misc matches', function () { '
      ' + '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -61,7 +61,7 @@ describe('duplicate-id-misc matches', function () { fixtureSetup( '' + '
      ' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'button[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -71,7 +71,7 @@ describe('duplicate-id-misc matches', function () { '
      ' + '' ); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'span[id=foo]')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); }); diff --git a/test/rule-matches/frame-focusable-content-matches.js b/test/rule-matches/frame-focusable-content-matches.js index 8adc9ef5b7..996397bc2b 100644 --- a/test/rule-matches/frame-focusable-content-matches.js +++ b/test/rule-matches/frame-focusable-content-matches.js @@ -1,13 +1,13 @@ describe('frame-focusable-content-matches', function () { 'use strict'; - var rule; + let rule; beforeEach(function () { rule = axe.utils.getRule('frame-focusable-content'); }); it('returns false for the top-level context', function () { - var result = rule.matches(null, null, { + const result = rule.matches(null, null, { initiator: true, focusable: false, size: { @@ -19,7 +19,7 @@ describe('frame-focusable-content-matches', function () { }); it('returns false for focusable iframes', function () { - var result = rule.matches(null, null, { + const result = rule.matches(null, null, { initiator: false, focusable: true, size: { @@ -31,7 +31,7 @@ describe('frame-focusable-content-matches', function () { }); it('returns false for non-focusable iframes that are too small (1x1)', function () { - var result = rule.matches(null, null, { + const result = rule.matches(null, null, { initiator: false, focusable: false, size: { @@ -43,7 +43,7 @@ describe('frame-focusable-content-matches', function () { }); it('returns false for non-focusable iframes that are too small (0x0)', function () { - var result = rule.matches(null, null, { + const result = rule.matches(null, null, { initiator: false, focusable: false, size: { @@ -55,7 +55,7 @@ describe('frame-focusable-content-matches', function () { }); it('returns true for non-focusable iframes', function () { - var result = rule.matches(null, null, { + const result = rule.matches(null, null, { initiator: false, focusable: false, size: { diff --git a/test/rule-matches/frame-title-has-text-matches.js b/test/rule-matches/frame-title-has-text-matches.js index cb9bbe42fc..c72859888a 100644 --- a/test/rule-matches/frame-title-has-text-matches.js +++ b/test/rule-matches/frame-title-has-text-matches.js @@ -1,8 +1,8 @@ describe('layout-table-matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var rule; + const fixture = document.getElementById('fixture'); + let rule; beforeEach(function () { rule = axe.utils.getRule('frame-title-unique'); @@ -14,19 +14,19 @@ describe('layout-table-matches', function () { it('should return true if title attribute has text', function () { fixture.innerHTML = ''; - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isTrue(rule.matches(node)); }); it('should return false if title attribute is empty', function () { fixture.innerHTML = ''; - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isFalse(rule.matches(node)); }); it('should return false if title attribute contains only whitespace', function () { fixture.innerHTML = ''; - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isFalse(rule.matches(node)); }); }); diff --git a/test/rule-matches/has-implicit-chromium-role-matches.js b/test/rule-matches/has-implicit-chromium-role-matches.js index 55c54807c0..448cb2070d 100644 --- a/test/rule-matches/has-implicit-chromium-role-matches.js +++ b/test/rule-matches/has-implicit-chromium-role-matches.js @@ -1,9 +1,9 @@ describe('has-implicit-chromium-role-matches', function () { 'use strict'; - var rule; - var fixture = document.getElementById('fixture'); - var queryFixture = axe.testUtils.queryFixture; + let rule; + const fixture = document.getElementById('fixture'); + const queryFixture = axe.testUtils.queryFixture; beforeEach(function () { rule = axe.utils.getRule('presentation-role-conflict'); @@ -18,22 +18,22 @@ describe('has-implicit-chromium-role-matches', function () { }); it('matches elements with an implicit role', function () { - var vNode = queryFixture('
      '); + const vNode = queryFixture('
      '); assert.isTrue(rule.matches(null, vNode)); }); it('does not match elements with no implicit role', function () { - var vNode = queryFixture('
      '); + const vNode = queryFixture('
      '); assert.isFalse(rule.matches(null, vNode)); }); it('matches elements with an implicit role in chromium', function () { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isTrue(rule.matches(null, vNode)); }); it('does not match elements with no implicit role even if they are focusable and have an explicit role', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
      ' ); assert.isFalse(rule.matches(null, vNode)); diff --git a/test/rule-matches/heading-matches.js b/test/rule-matches/heading-matches.js index 4939f16b9f..59f8250540 100644 --- a/test/rule-matches/heading-matches.js +++ b/test/rule-matches/heading-matches.js @@ -1,8 +1,8 @@ describe('heading-matches', function () { 'use strict'; - var queryFixture = axe.testUtils.queryFixture; - var fixtureSetup = axe.testUtils.fixtureSetup; - var rule; + const queryFixture = axe.testUtils.queryFixture; + const fixtureSetup = axe.testUtils.fixtureSetup; + let rule; beforeEach(function () { rule = axe.utils.getRule('empty-heading'); @@ -13,39 +13,41 @@ describe('heading-matches', function () { }); it('should return false on elements that are not headings', function () { - var vNode = fixtureSetup('
      '); + const vNode = fixtureSetup('
      '); assert.isFalse(rule.matches(null, vNode)); }); it('should return true on elements with role="heading"', function () { - var vNode = queryFixture('
      '); + const vNode = queryFixture('
      '); assert.isTrue(rule.matches(null, vNode)); }); it('should return true on regular headings without roles', function () { - for (var i = 1; i <= 6; i++) { - var vNode = queryFixture(''); + for (let i = 1; i <= 6; i++) { + const vNode = queryFixture(''); assert.isTrue(rule.matches(null, vNode)); } }); it('should return false on headings with their role changes', function () { - var vNode = queryFixture('

      '); + const vNode = queryFixture('

      '); assert.isFalse(rule.matches(null, vNode)); }); it('should return true on headings with their role changes to an invalid role', function () { - var vNode = queryFixture('

      '); + const vNode = queryFixture('

      '); assert.isTrue(rule.matches(null, vNode)); }); it('should return true on headings with their role changes to an abstract role', function () { - var vNode = queryFixture('

      '); + const vNode = queryFixture('

      '); assert.isTrue(rule.matches(null, vNode)); }); it('should return true on headings with explicit role="none" and an empty aria-label to account for presentation conflict resolution', function () { - var vNode = queryFixture('

      '); + const vNode = queryFixture( + '

      ' + ); assert.isTrue(rule.matches(null, vNode)); }); }); diff --git a/test/rule-matches/html-namespace-matches.js b/test/rule-matches/html-namespace-matches.js index 48ff0a2667..c6582e7ee7 100644 --- a/test/rule-matches/html-namespace-matches.js +++ b/test/rule-matches/html-namespace-matches.js @@ -1,8 +1,8 @@ describe('html-namespace-matches', function () { 'use strict'; - var rule; - var fixture; - var axeFixtureSetup; + let rule; + let fixture; + let axeFixtureSetup; beforeEach(function () { fixture = document.getElementById('fixture'); @@ -16,22 +16,22 @@ describe('html-namespace-matches', function () { it('returns true when passed an HTML element', function () { axeFixtureSetup('

      Hello world

      '); - var node = fixture.querySelector('h1'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector('h1'); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isTrue(rule.matches(node, virtualNode)); }); it('returns true when passed a custom HTML element', function () { axeFixtureSetup('Hello world'); - var node = fixture.querySelector('xx-heading'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector('xx-heading'); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isTrue(rule.matches(node, virtualNode)); }); it('returns false when passed an SVG element', function () { axeFixtureSetup('Pretty picture'); - var node = fixture.querySelector('svg'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector('svg'); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isFalse(rule.matches(node, virtualNode)); }); @@ -39,14 +39,14 @@ describe('html-namespace-matches', function () { axeFixtureSetup( 'Pretty picture' ); - var node = fixture.querySelector('circle'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector('circle'); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isFalse(rule.matches(node, virtualNode)); }); describe('Serial Virtual Node', function () { it('returns true when passed an HTML element', function () { - var serialNode = new axe.SerialVirtualNode({ + const serialNode = new axe.SerialVirtualNode({ nodeName: 'h1' }); serialNode.parent = null; @@ -55,7 +55,7 @@ describe('html-namespace-matches', function () { }); it('returns true when passed a custom HTML element', function () { - var serialNode = new axe.SerialVirtualNode({ + const serialNode = new axe.SerialVirtualNode({ nodeName: 'xx-heading' }); serialNode.parent = null; @@ -64,10 +64,10 @@ describe('html-namespace-matches', function () { }); it('returns false when passed an SVG circle element', function () { - var serialNode = new axe.SerialVirtualNode({ + const serialNode = new axe.SerialVirtualNode({ nodeName: 'circle' }); - var parent = new axe.SerialVirtualNode({ + const parent = new axe.SerialVirtualNode({ nodeName: 'svg' }); serialNode.parent = parent; diff --git a/test/rule-matches/html-xml-lang-mismatch.js b/test/rule-matches/html-xml-lang-mismatch.js index b710aef5ca..cbac5a1fd8 100644 --- a/test/rule-matches/html-xml-lang-mismatch.js +++ b/test/rule-matches/html-xml-lang-mismatch.js @@ -3,9 +3,9 @@ describe('xml-lang-mismatch-matches', function () { // nested this on a per rule basis, for future-proofing writing tests for multiple rules using the same matches describe('for rule: html-xml-lang-mismatch', function () { - var rule; - var dom; - var fixture = document.getElementById('fixture'); + let rule; + let dom; + const fixture = document.getElementById('fixture'); beforeEach(function () { rule = axe.utils.getRule('html-xml-lang-mismatch'); @@ -17,33 +17,33 @@ describe('xml-lang-mismatch-matches', function () { }); it('is a function', function () { - var actual = rule.matches; + const actual = rule.matches; assert.isFunction(actual); }); it('returns false if the element does not contain lang or xml:lang attribute', function () { - var actual = rule.matches(dom); + const actual = rule.matches(dom); assert.isFalse(actual); }); it('returns false if the element contains either/ only one of the lang or xml:lang attribute', function () { dom.setAttribute('lang', 'nl'); - var actual = rule.matches(dom); + const actual = rule.matches(dom); assert.isFalse(actual); }); it('returns true if the element contains both lang and xml:lang attribute', function () { dom.setAttribute('lang', 'en'); dom.setAttribute('xml:lang', 'nl'); - var actual = rule.matches(dom); + const actual = rule.matches(dom); assert.isTrue(actual); }); it('returns false for element of type that is not HTML', function () { - var node = document.createElement('svg'); + const node = document.createElement('svg'); node.setAttribute('lang', ''); node.setAttribute('xml:lang', 'nl'); - var actual = rule.matches(node); + const actual = rule.matches(node); assert.isFalse(actual); }); }); diff --git a/test/rule-matches/identical-links-same-purpose-matches.js b/test/rule-matches/identical-links-same-purpose-matches.js index 9aa044bd08..7e130d8c88 100644 --- a/test/rule-matches/identical-links-same-purpose-matches.js +++ b/test/rule-matches/identical-links-same-purpose-matches.js @@ -1,9 +1,9 @@ describe('identical-links-same-purpose-matches tests', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var queryFixture = axe.testUtils.queryFixture; - var rule = axe.utils.getRule('identical-links-same-purpose'); + const fixture = document.getElementById('fixture'); + const queryFixture = axe.testUtils.queryFixture; + const rule = axe.utils.getRule('identical-links-same-purpose'); afterEach(function () { fixture.innerHTML = ''; @@ -11,79 +11,81 @@ describe('identical-links-same-purpose-matches tests', function () { }); it('returns false when native link without accessible name', function () { - var vNode = queryFixture(''); - var actual = rule.matches(vNode.actualNode, vNode); + const vNode = queryFixture(''); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false for ARIA link without accessible name', function () { - var vNode = queryFixture(''); - var actual = rule.matches(vNode.actualNode, vNode); + const vNode = queryFixture(''); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false for native link with a role !== link', function () { - var vNode = queryFixture( + const vNode = queryFixture( 'Go to Checkout' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false when `area` has no parent `map` element', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false when `area` has parent `map` that is not referred by `img[usemap]`', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' + '' + '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns true when native link without href', function () { - var vNode = queryFixture('Book Now'); - var actual = rule.matches(vNode.actualNode, vNode); + const vNode = queryFixture('Book Now'); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); it('returns true when ARIA link without href', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); it('returns true when native link has an accessible name', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); it('returns true for ARIA link has an accessible name', function () { - var vNode = queryFixture('Book Tour'); - var actual = rule.matches(vNode.actualNode, vNode); + const vNode = queryFixture( + 'Book Tour' + ); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); it('returns true when `area` has parent `map` that is referred by `img`', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' + '' + '' + 'MDN infographic' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); }); diff --git a/test/rule-matches/inserted-into-focus-order-matches.js b/test/rule-matches/inserted-into-focus-order-matches.js index f9a56f3ed2..ff7ec134f8 100644 --- a/test/rule-matches/inserted-into-focus-order-matches.js +++ b/test/rule-matches/inserted-into-focus-order-matches.js @@ -1,9 +1,9 @@ describe('inserted-into-focus-order-matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var flatTreeSetup = axe.testUtils.flatTreeSetup; - var rule; + const fixture = document.getElementById('fixture'); + const flatTreeSetup = axe.testUtils.flatTreeSetup; + let rule; beforeEach(function () { rule = axe.utils.getRule('focus-order-semantics'); @@ -16,35 +16,35 @@ describe('inserted-into-focus-order-matches', function () { it('should return true for a non-focusable element with tabindex > -1', function () { fixture.innerHTML = '
      '; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isTrue(rule.matches(node)); }); it('should return false for a non-focusable element with tabindex == -1', function () { fixture.innerHTML = '
      '; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isFalse(rule.matches(node)); }); it('should return false for a native focusable element with tabindex > 0', function () { fixture.innerHTML = ''; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isFalse(rule.matches(node)); }); it('should return false for a native focusable element with no tabindex', function () { fixture.innerHTML = ''; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isFalse(rule.matches(node)); }); it('should return false for non-numeric tabindex value', function () { fixture.innerHTML = '
      '; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isFalse(rule.matches(node)); }); }); diff --git a/test/rule-matches/is-initiator-matches.js b/test/rule-matches/is-initiator-matches.js index 8007f1f56a..91199ed245 100644 --- a/test/rule-matches/is-initiator-matches.js +++ b/test/rule-matches/is-initiator-matches.js @@ -1,14 +1,14 @@ describe('is-initiator-matches', function () { 'use strict'; - var rule; + let rule; beforeEach(function () { rule = axe.utils.getRule('html-has-lang'); }); afterEach(function () { - var fixture = document.getElementById('fixture'); + const fixture = document.getElementById('fixture'); fixture.innerHTML = ''; }); diff --git a/test/rule-matches/is-visible-matches.js b/test/rule-matches/is-visible-matches.js index 847b796c25..b860986843 100644 --- a/test/rule-matches/is-visible-matches.js +++ b/test/rule-matches/is-visible-matches.js @@ -1,12 +1,12 @@ describe('is-visible-matches', function () { 'use strict'; - var isVisibleMatches = + let isVisibleMatches = axe._thisWillBeDeletedDoNotUse.base.metadataFunctionMap[ 'is-visible-matches' ]; - var fixture = document.getElementById('fixture'); - var fixtureSetup = axe.testUtils.fixtureSetup; + let fixture = document.getElementById('fixture'); + let fixtureSetup = axe.testUtils.fixtureSetup; it('returns true for visible elements', function () { fixtureSetup('

      Hello world

      '); diff --git a/test/rule-matches/label-content-name-mismatch-matches.js b/test/rule-matches/label-content-name-mismatch-matches.js index b47d2847d1..7252a98e83 100644 --- a/test/rule-matches/label-content-name-mismatch-matches.js +++ b/test/rule-matches/label-content-name-mismatch-matches.js @@ -1,9 +1,9 @@ describe('label-content-name-mismatch-matches tests', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var queryFixture = axe.testUtils.queryFixture; - var rule = axe.utils.getRule('label-content-name-mismatch'); + const fixture = document.getElementById('fixture'); + const queryFixture = axe.testUtils.queryFixture; + const rule = axe.utils.getRule('label-content-name-mismatch'); afterEach(function () { fixture.innerHTML = ''; @@ -11,145 +11,145 @@ describe('label-content-name-mismatch-matches tests', function () { }); it('returns false if given element has no role', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
      ' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false if element role is not supported with name from contents', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
      20 %
      ' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false if implicit element role is overridden to a role that does not support name from contents', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
      Status message
      ' + '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false if element does not have accessible name attributes (`aria-label` or `aria-labelledby`)', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false if element has empty accessible name via `aria-label`', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns true if element has accessible name via `aria-label`', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); it('returns true if element has accessible name via `aria-labelledby`', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
      some content
      ' + '
      Foo text
      ' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); it('returns false if element has empty accessible name (`aria-labelledby`)', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
      some content
      ' + '
      ' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false if element has empty accessible name (`aria-labelledby`) because idref does not exist', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
      some content
      ' + '
      Right Label
      ' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns true if element has accessible name (`aria-labelledby`) - multiple refs', function () { - var vNode = queryFixture( + const vNode = queryFixture( '
      some content
      ' + '
      Foo
      ' + '
      Bar
      ' + '
      Baz
      ' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); it('returns false for non-widget role', function () { - var vNode = queryFixture( + const vNode = queryFixture( 'Content Information' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false for non-widget role that does support name from content', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false for empty text content', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false for non text content', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns false for hidden (non visible) text content', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isFalse(actual); }); it('returns true when visible text is combination of alphanumeric and emoji characters', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); it('returns true when visible text is combination of alphanumeric and punctuation characters', function () { - var vNode = queryFixture( + const vNode = queryFixture( '' ); - var actual = rule.matches(vNode.actualNode, vNode); + const actual = rule.matches(vNode.actualNode, vNode); assert.isTrue(actual); }); }); diff --git a/test/rule-matches/label-matches.js b/test/rule-matches/label-matches.js index 8dbdc304db..4e4058920f 100644 --- a/test/rule-matches/label-matches.js +++ b/test/rule-matches/label-matches.js @@ -1,9 +1,9 @@ describe('label-matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var queryFixture = axe.testUtils.queryFixture; - var rule; + const fixture = document.getElementById('fixture'); + const queryFixture = axe.testUtils.queryFixture; + let rule; beforeEach(function () { fixture.innerHTML = ''; @@ -11,25 +11,25 @@ describe('label-matches', function () { }); it('returns true for non-input elements', function () { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isTrue(rule.matches(null, vNode)); }); it('returns true for input elements without type', function () { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isTrue(rule.matches(null, vNode)); }); it('returns false for input buttons', function () { ['button', 'submit', 'image', 'reset'].forEach(function (type) { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isFalse(rule.matches(null, vNode)); }); }); it('returns false for input elements type=hidden', function () { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isFalse(rule.matches(null, vNode)); }); @@ -37,7 +37,7 @@ describe('label-matches', function () { it('returns true for other input types', function () { ['text', 'password', 'url', 'range', 'date', 'checkbox', 'radio'].forEach( function (type) { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isTrue(rule.matches(null, vNode)); } ); diff --git a/test/rule-matches/landmark-has-body-context.js b/test/rule-matches/landmark-has-body-context.js index 124ba3dc9e..3afa72e0b7 100644 --- a/test/rule-matches/landmark-has-body-context.js +++ b/test/rule-matches/landmark-has-body-context.js @@ -1,8 +1,8 @@ describe('landmark-has-body-context', function () { 'use strict'; - var fixtureSetup = axe.testUtils.fixtureSetup; - var rule; - var shadowSupport = axe.testUtils.shadowSupport.v1; + const fixtureSetup = axe.testUtils.fixtureSetup; + let rule; + const shadowSupport = axe.testUtils.shadowSupport.v1; beforeEach(function () { rule = axe.utils.getRule('landmark-banner-is-top-level'); @@ -11,21 +11,21 @@ describe('landmark-has-body-context', function () { it('returns true for elements with a role', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); it('returns true for elements not contained in a landmark', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); it('returns false for elements contained in a landmark', function () { fixtureSetup('
      '); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); }); @@ -35,12 +35,12 @@ describe('landmark-has-body-context', function () { // Safari has a bug in 12.0 that throws an error when calling // attachShadow on
      // @see https://bugs.webkit.org/show_bug.cgi?id=197726 - var article = document.createElement('article'); - var shadow = article.attachShadow({ mode: 'open' }); + const article = document.createElement('article'); + const shadow = article.attachShadow({ mode: 'open' }); shadow.innerHTML = '
      '; fixtureSetup(article); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; assert.isFalse(rule.matches(vNode.actualNode, vNode)); } ); diff --git a/test/rule-matches/landmark-unique-matches.js b/test/rule-matches/landmark-unique-matches.js index 518763d953..cb3cef7bde 100644 --- a/test/rule-matches/landmark-unique-matches.js +++ b/test/rule-matches/landmark-unique-matches.js @@ -1,13 +1,13 @@ describe('landmark-unique-matches', function () { 'use strict'; - var rule; - var fixture; - var axeFixtureSetup; - var shadowSupport = axe.testUtils.shadowSupport.v1; - var sectioningContentElements = ['article', 'aside', 'nav', 'section']; - var excludedDescendantsForHeadersFooters = + let rule; + let fixture; + let axeFixtureSetup; + const shadowSupport = axe.testUtils.shadowSupport.v1; + const sectioningContentElements = ['article', 'aside', 'nav', 'section']; + const excludedDescendantsForHeadersFooters = sectioningContentElements.concat('main'); - var headerFooterElements = ['header', 'footer']; + const headerFooterElements = ['header', 'footer']; beforeEach(function () { fixture = document.getElementById('fixture'); @@ -17,30 +17,30 @@ describe('landmark-unique-matches', function () { it('should not match because not a landmark', function () { axeFixtureSetup('

      some heading

      '); - var node = fixture.querySelector('h1'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector('h1'); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isFalse(rule.matches(node, virtualNode)); }); it('should pass because is a landmark', function () { axeFixtureSetup('
      some banner
      '); - var node = fixture.querySelector('div'); + const node = fixture.querySelector('div'); fixture.appendChild(node); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isTrue(rule.matches(node, virtualNode)); }); it('should not match because landmark is hidden', function () { axeFixtureSetup('
      some banner
      '); - var node = fixture.querySelector('div'); + const node = fixture.querySelector('div'); node.style.display = 'none'; fixture.appendChild(node); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isFalse(rule.matches(node, virtualNode)); }); describe('form and section elements must have accessible names to be matched', function () { - var sectionFormElements = ['section', 'form']; + const sectionFormElements = ['section', 'form']; sectionFormElements.forEach(function (elementType) { it( @@ -55,8 +55,8 @@ describe('landmark-unique-matches', function () { elementType + '>' ); - var node = fixture.querySelector(elementType); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector(elementType); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isTrue(rule.matches(node, virtualNode)); } ); @@ -73,8 +73,8 @@ describe('landmark-unique-matches', function () { elementType + '>' ); - var node = fixture.querySelector(elementType); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector(elementType); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isFalse(rule.matches(node, virtualNode)); } ); @@ -101,8 +101,8 @@ describe('landmark-unique-matches', function () { exclusionType + '>' ); - var node = fixture.querySelector(elementType); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector(elementType); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isFalse(rule.matches(node, virtualNode)); } ); @@ -116,8 +116,8 @@ describe('landmark-unique-matches', function () { axeFixtureSetup( '<' + elementType + '>an element' ); - var node = fixture.querySelector(elementType); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector(elementType); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isTrue(rule.matches(node, virtualNode)); } ); @@ -138,8 +138,8 @@ describe('landmark-unique-matches', function () { exclusionType + '>' ); - var node = fixture.querySelector('aside[data-test]'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector('aside[data-test]'); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isFalse(rule.matches(node, virtualNode)); } ); @@ -154,8 +154,8 @@ describe('landmark-unique-matches', function () { exclusionType + '>' ); - var node = fixture.querySelector('aside[data-test]'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector('aside[data-test]'); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isTrue(rule.matches(node, virtualNode)); } ); @@ -163,26 +163,26 @@ describe('landmark-unique-matches', function () { it('should match because aside is not scoped to a sectioning content element', function () { axeFixtureSetup(''); - var node = fixture.querySelector('aside'); - var virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); + const node = fixture.querySelector('aside'); + const virtualNode = axe.utils.getNodeFromTree(axe._tree[0], node); assert.isTrue(rule.matches(node, virtualNode)); }); }); if (shadowSupport) { it('return true for landmarks contained within shadow dom', function () { - var container = document.createElement('div'); - var shadow = container.attachShadow({ mode: 'open' }); + const container = document.createElement('div'); + const shadow = container.attachShadow({ mode: 'open' }); shadow.innerHTML = '
      '; axeFixtureSetup(container); - var vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; + const vNode = axe.utils.querySelectorAll(axe._tree[0], 'footer')[0]; assert.isTrue(rule.matches(vNode.actualNode, vNode)); }); describe('header/footers should only match when not inside the excluded descendants within shadow dom', function () { - var container; - var shadow; + let container; + let shadow; beforeEach(function () { container = document.createElement('div'); @@ -210,7 +210,7 @@ describe('landmark-unique-matches', function () { '>'; axeFixtureSetup(container); - var virtualNode = axe.utils.querySelectorAll( + const virtualNode = axe.utils.querySelectorAll( axe._tree[0], elementType )[0]; @@ -227,7 +227,7 @@ describe('landmark-unique-matches', function () { shadow.innerHTML = '<' + elementType + '>an element'; axeFixtureSetup(container); - var virtualNode = axe.utils.querySelectorAll( + const virtualNode = axe.utils.querySelectorAll( axe._tree[0], elementType )[0]; @@ -238,8 +238,8 @@ describe('landmark-unique-matches', function () { }); describe('aside should match inside shadow dom unless it is both within sectioning content and has no accessible name', function () { - var container; - var shadow; + let container; + let shadow; beforeEach(function () { container = document.createElement('div'); @@ -260,7 +260,7 @@ describe('landmark-unique-matches', function () { '>'; axeFixtureSetup(container); - var virtualNode = axe.utils.querySelectorAll( + const virtualNode = axe.utils.querySelectorAll( axe._tree[0], 'aside[data-test]' )[0]; @@ -278,7 +278,7 @@ describe('landmark-unique-matches', function () { exclusionType + '>'; axeFixtureSetup(container); - var virtualNode = axe.utils.querySelectorAll( + const virtualNode = axe.utils.querySelectorAll( axe._tree[0], 'aside[data-test]' )[0]; @@ -290,7 +290,10 @@ describe('landmark-unique-matches', function () { it('should match because aside is not scoped to a sectioning content element', function () { shadow.innerHTML = ''; axeFixtureSetup(container); - var virtualNode = axe.utils.querySelectorAll(axe._tree[0], 'aside')[0]; + const virtualNode = axe.utils.querySelectorAll( + axe._tree[0], + 'aside' + )[0]; assert.isTrue(rule.matches(virtualNode.actualNode, virtualNode)); }); }); diff --git a/test/rule-matches/layout-table-matches.js b/test/rule-matches/layout-table-matches.js index cae2b1ff73..c86cb5ac37 100644 --- a/test/rule-matches/layout-table-matches.js +++ b/test/rule-matches/layout-table-matches.js @@ -1,9 +1,9 @@ describe('layout-table-matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var flatTreeSetup = axe.testUtils.flatTreeSetup; - var rule; + const fixture = document.getElementById('fixture'); + const flatTreeSetup = axe.testUtils.flatTreeSetup; + let rule; beforeEach(function () { axe.configure({ @@ -26,7 +26,7 @@ describe('layout-table-matches', function () { it('should return false for data table', function () { fixture.innerHTML = '
      Hello>
      '; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isFalse(rule.matches(node)); }); @@ -34,7 +34,7 @@ describe('layout-table-matches', function () { it('should return false if the table is focusable', function () { fixture.innerHTML = '
      '; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isFalse(rule.matches(node)); }); @@ -42,7 +42,7 @@ describe('layout-table-matches', function () { it('should return true if table has role=presentation', function () { fixture.innerHTML = '
      '; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isTrue(rule.matches(node)); }); @@ -50,7 +50,7 @@ describe('layout-table-matches', function () { it('should return true if table has role=none', function () { fixture.innerHTML = '
      '; flatTreeSetup(fixture); - var node = fixture.firstChild; + const node = fixture.firstChild; assert.isTrue(rule.matches(node)); }); diff --git a/test/rule-matches/nested-interactive-matches.js b/test/rule-matches/nested-interactive-matches.js index c4bebe5148..9c76d7082c 100644 --- a/test/rule-matches/nested-interactive-matches.js +++ b/test/rule-matches/nested-interactive-matches.js @@ -1,7 +1,7 @@ describe('nested-interactive-matches', function () { - var fixture = document.querySelector('#fixture'); - var queryFixture = axe.testUtils.queryFixture; - var rule; + const fixture = document.querySelector('#fixture'); + const queryFixture = axe.testUtils.queryFixture; + let rule; beforeEach(function () { rule = axe.utils.getRule('nested-interactive'); @@ -12,22 +12,22 @@ describe('nested-interactive-matches', function () { }); it('should match if element has children presentational', function () { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isTrue(rule.matches(null, vNode)); }); it('should match if aria element has children presentational', function () { - var vNode = queryFixture('
      '); + const vNode = queryFixture('
      '); assert.isTrue(rule.matches(null, vNode)); }); it('should not match if element does not have children presentational', function () { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isFalse(rule.matches(null, vNode)); }); it('should not match if element has no role', function () { - var vNode = queryFixture(''); + const vNode = queryFixture(''); assert.isFalse(rule.matches(null, vNode)); }); }); diff --git a/test/rule-matches/no-autoplay-audio-matches.js b/test/rule-matches/no-autoplay-audio-matches.js index 1769e3e897..037582cbf9 100644 --- a/test/rule-matches/no-autoplay-audio-matches.js +++ b/test/rule-matches/no-autoplay-audio-matches.js @@ -1,10 +1,10 @@ describe('no-autoplay-audio-matches', function () { 'use strict'; - var fixture = document.getElementById('fixture'); - var queryFixture = axe.testUtils.queryFixture; - var preloadOptions = { preload: { assets: ['media'] } }; - var rule; + const fixture = document.getElementById('fixture'); + const queryFixture = axe.testUtils.queryFixture; + const preloadOptions = { preload: { assets: ['media'] } }; + let rule; beforeEach(function () { rule = axe.utils.getRule('no-autoplay-audio'); @@ -15,37 +15,37 @@ describe('no-autoplay-audio-matches', function () { }); it('returns false for