From 8dfca151f90b2076ba9f6cefc50e8b35b8db4deb Mon Sep 17 00:00:00 2001 From: jkodu Date: Fri, 2 Nov 2018 15:43:58 +0000 Subject: [PATCH 1/2] fix: replace node.tagName usage with node.nodeName --- lib/checks/aria/required-children.js | 2 +- lib/checks/aria/valid-scrollable-semantics.js | 4 ++-- lib/checks/keyboard/landmark-is-top-level.js | 2 +- lib/checks/label/multiple-label.js | 5 ++++- lib/checks/navigation/heading-order.js | 2 +- lib/checks/navigation/region.js | 2 +- lib/checks/visibility/hidden-content.js | 2 +- lib/commons/dom/is-visual-content.js | 2 +- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/checks/aria/required-children.js b/lib/checks/aria/required-children.js index 7049810bef..1eb68c1871 100644 --- a/lib/checks/aria/required-children.js +++ b/lib/checks/aria/required-children.js @@ -65,7 +65,7 @@ function missingRequiredChildren(node, childRoles, all, role) { var textTypeInputs = ['text', 'search', 'email', 'url', 'tel']; if ( textboxIndex >= 0 && - node.tagName === 'INPUT' && + node.nodeName.toUpperCase() === 'INPUT' && textTypeInputs.includes(node.type) ) { missing.splice(textboxIndex, 1); diff --git a/lib/checks/aria/valid-scrollable-semantics.js b/lib/checks/aria/valid-scrollable-semantics.js index cd304982ad..6e7c111fe7 100644 --- a/lib/checks/aria/valid-scrollable-semantics.js +++ b/lib/checks/aria/valid-scrollable-semantics.js @@ -33,8 +33,8 @@ const VALID_ROLES_FOR_SCROLLABLE_REGIONS = { function validScrollableTagName(node) { // Some elements with nonsensical roles will pass this check, but should be // flagged by other checks. - var tagName = node.tagName.toUpperCase(); - return VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS[tagName] || false; + const nodeName = node.nodeName.toUpperCase(); + return VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS[nodeName] || false; } /** diff --git a/lib/checks/keyboard/landmark-is-top-level.js b/lib/checks/keyboard/landmark-is-top-level.js index a00b575c23..7c30413163 100644 --- a/lib/checks/keyboard/landmark-is-top-level.js +++ b/lib/checks/keyboard/landmark-is-top-level.js @@ -7,7 +7,7 @@ this.data({ while (parent) { var role = parent.getAttribute('role'); - if (!role && parent.tagName.toLowerCase() !== 'form') { + if (!role && parent.nodeName.toUpperCase() !== 'FORM') { role = axe.commons.aria.implicitRole(parent); } if (role && landmarks.includes(role)) { diff --git a/lib/checks/label/multiple-label.js b/lib/checks/label/multiple-label.js index 315fece822..94b121124b 100644 --- a/lib/checks/label/multiple-label.js +++ b/lib/checks/label/multiple-label.js @@ -16,7 +16,10 @@ if (labels.length) { } while (parent) { - if (parent.tagName === 'LABEL' && labels.indexOf(parent) === -1) { + if ( + parent.nodeName.toUpperCase() === 'LABEL' && + labels.indexOf(parent) === -1 + ) { labels.push(parent); } parent = parent.parentNode; diff --git a/lib/checks/navigation/heading-order.js b/lib/checks/navigation/heading-order.js index 64d78379c5..8d6e7e133f 100644 --- a/lib/checks/navigation/heading-order.js +++ b/lib/checks/navigation/heading-order.js @@ -5,7 +5,7 @@ if (ariaHeadingLevel !== null) { return true; } -var headingLevel = node.tagName.match(/H(\d)/); +var headingLevel = node.nodeName.match(/H(\d)/); if (headingLevel) { this.data(parseInt(headingLevel[1], 10)); diff --git a/lib/checks/navigation/region.js b/lib/checks/navigation/region.js index e273ba4116..653146f21f 100644 --- a/lib/checks/navigation/region.js +++ b/lib/checks/navigation/region.js @@ -41,7 +41,7 @@ function isRegion(virtualNode) { // Check if the node matches any of the CSS selectors of implicit landmarks return implicitLandmarks.some(implicitSelector => { let matches = axe.utils.matchesSelector(node, implicitSelector); - if (node.tagName.toLowerCase() === 'form') { + if (node.nodeName.toUpperCase() === 'FORM') { let titleAttr = node.getAttribute('title'); let title = titleAttr && titleAttr.trim() !== '' diff --git a/lib/checks/visibility/hidden-content.js b/lib/checks/visibility/hidden-content.js index c97b5c36d2..cbfdb763a4 100644 --- a/lib/checks/visibility/hidden-content.js +++ b/lib/checks/visibility/hidden-content.js @@ -1,6 +1,6 @@ const whitelist = ['SCRIPT', 'HEAD', 'TITLE', 'NOSCRIPT', 'STYLE', 'TEMPLATE']; if ( - !whitelist.includes(node.tagName.toUpperCase()) && + !whitelist.includes(node.nodeName.toUpperCase()) && axe.commons.dom.hasContentVirtual(virtualNode) ) { const styles = window.getComputedStyle(node); diff --git a/lib/commons/dom/is-visual-content.js b/lib/commons/dom/is-visual-content.js index 63813009ba..832ac53aa7 100644 --- a/lib/commons/dom/is-visual-content.js +++ b/lib/commons/dom/is-visual-content.js @@ -26,7 +26,7 @@ dom.isVisualContent = function(element) { return visualRoles.indexOf(role) !== -1; } - switch (element.tagName.toUpperCase()) { + switch (element.nodeName.toUpperCase()) { case 'IMG': case 'IFRAME': case 'OBJECT': From 942a6bd581b363a0ae7496aaa48ba8396f3a96ab Mon Sep 17 00:00:00 2001 From: jkodu Date: Thu, 8 Nov 2018 14:17:45 +0000 Subject: [PATCH 2/2] fix: uppercase nodename for regex match --- lib/checks/navigation/heading-order.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checks/navigation/heading-order.js b/lib/checks/navigation/heading-order.js index 8d6e7e133f..cb871d2aaf 100644 --- a/lib/checks/navigation/heading-order.js +++ b/lib/checks/navigation/heading-order.js @@ -5,7 +5,7 @@ if (ariaHeadingLevel !== null) { return true; } -var headingLevel = node.nodeName.match(/H(\d)/); +var headingLevel = node.nodeName.toUpperCase().match(/H(\d)/); if (headingLevel) { this.data(parseInt(headingLevel[1], 10));