From db2be93d07dda488f9d5ca66d193709eb41bf8cd Mon Sep 17 00:00:00 2001 From: Steven Lambert <2433219+straker@users.noreply.github.com> Date: Mon, 28 Sep 2020 09:14:55 -0600 Subject: [PATCH] feat(rule-matches): depreacte window-is-top-matches for is-intiator-matches (#2531) --- lib/core/base/metadata-function-map.js | 2 ++ lib/rules/bypass-matches.js | 6 +++--- lib/rules/document-title.json | 2 +- lib/rules/html-has-lang.json | 2 +- lib/rules/is-initiator-matches.js | 5 +++++ lib/rules/window-is-top-matches.js | 1 + test/rule-matches/is-initiator-matches.js | 24 +++++++++++++++++++++++ 7 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 lib/rules/is-initiator-matches.js create mode 100644 test/rule-matches/is-initiator-matches.js diff --git a/lib/core/base/metadata-function-map.js b/lib/core/base/metadata-function-map.js index f80a570d22..3196646263 100644 --- a/lib/core/base/metadata-function-map.js +++ b/lib/core/base/metadata-function-map.js @@ -145,6 +145,7 @@ import headingMatches from '../../rules/heading-matches'; import htmlNamespaceMatches from '../../rules/html-namespace-matches'; import identicalLinksSamePurposeMatches from '../../rules/identical-links-same-purpose-matches'; import insertedIntoFocusOrderMatches from '../../rules/inserted-into-focus-order-matches'; +import isInitiatorMatches from '../../rules/is-initiator-matches'; import labelContentNameMismatchMatches from '../../rules/label-content-name-mismatch-matches'; import labelMatches from '../../rules/label-matches'; import landmarkHasBodyContextMatches from '../../rules/landmark-has-body-context-matches'; @@ -310,6 +311,7 @@ const metadataFunctionMap = { 'html-namespace-matches': htmlNamespaceMatches, 'identical-links-same-purpose-matches': identicalLinksSamePurposeMatches, 'inserted-into-focus-order-matches': insertedIntoFocusOrderMatches, + 'is-initiator-matches': isInitiatorMatches, 'label-content-name-mismatch-matches': labelContentNameMismatchMatches, 'label-matches': labelMatches, 'landmark-has-body-context-matches': landmarkHasBodyContextMatches, diff --git a/lib/rules/bypass-matches.js b/lib/rules/bypass-matches.js index 91d22f8165..f6fd2b2440 100644 --- a/lib/rules/bypass-matches.js +++ b/lib/rules/bypass-matches.js @@ -1,8 +1,8 @@ -import windowIsTopMatches from './window-is-top-matches'; +import isInitiatorMatches from './is-initiator-matches'; -function bypassMatches(node) { +function bypassMatches(node, virtualNode, context) { // the top level window should have an anchor - if (windowIsTopMatches(node)) { + if (isInitiatorMatches(node, virtualNode, context)) { return !!node.querySelector('a[href]'); } diff --git a/lib/rules/document-title.json b/lib/rules/document-title.json index 2aba304b6b..ceaa155fea 100644 --- a/lib/rules/document-title.json +++ b/lib/rules/document-title.json @@ -1,7 +1,7 @@ { "id": "document-title", "selector": "html", - "matches": "window-is-top-matches", + "matches": "is-initiator-matches", "tags": ["cat.text-alternatives", "wcag2a", "wcag242", "ACT"], "metadata": { "description": "Ensures each HTML document contains a non-empty