Skip to content

Commit cf86ff5

Browse files
jeeyyyWilcoFiers
authored andcommitted
fix: Avoid IE problems by using nodeName instead of tagName (#1219)
This is a maintenance PR, to update `node.tagName` usages to `node.nodeName`. Did not update the usages in: - `lib/core/utils/css-parser.js` - as this is a copy/pasted (imported) module. - `lib/core/utils/qsa.js` - as this seems to break a lot of tests. Closes issue: - #942 ## Reviewer checks **Required fields, to be filled out by PR reviewer(s)** - [x] Follows the commit message policy, appropriate for next version - [x] Has documentation updated, a DU ticket, or requires no documentation change - [x] Includes new tests, or was unnecessary - [x] Code is reviewed for security by: << Marcy Sutton >>
1 parent 2cff417 commit cf86ff5

File tree

8 files changed

+12
-9
lines changed

8 files changed

+12
-9
lines changed

lib/checks/aria/required-children.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function missingRequiredChildren(node, childRoles, all, role) {
6565
var textTypeInputs = ['text', 'search', 'email', 'url', 'tel'];
6666
if (
6767
textboxIndex >= 0 &&
68-
node.tagName === 'INPUT' &&
68+
node.nodeName.toUpperCase() === 'INPUT' &&
6969
textTypeInputs.includes(node.type)
7070
) {
7171
missing.splice(textboxIndex, 1);

lib/checks/aria/valid-scrollable-semantics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const VALID_ROLES_FOR_SCROLLABLE_REGIONS = {
3333
function validScrollableTagName(node) {
3434
// Some elements with nonsensical roles will pass this check, but should be
3535
// flagged by other checks.
36-
var tagName = node.tagName.toUpperCase();
37-
return VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS[tagName] || false;
36+
const nodeName = node.nodeName.toUpperCase();
37+
return VALID_TAG_NAMES_FOR_SCROLLABLE_REGIONS[nodeName] || false;
3838
}
3939

4040
/**

lib/checks/keyboard/landmark-is-top-level.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ this.data({
77

88
while (parent) {
99
var role = parent.getAttribute('role');
10-
if (!role && parent.tagName.toLowerCase() !== 'form') {
10+
if (!role && parent.nodeName.toUpperCase() !== 'FORM') {
1111
role = axe.commons.aria.implicitRole(parent);
1212
}
1313
if (role && landmarks.includes(role)) {

lib/checks/label/multiple-label.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ if (labels.length) {
1616
}
1717

1818
while (parent) {
19-
if (parent.tagName === 'LABEL' && labels.indexOf(parent) === -1) {
19+
if (
20+
parent.nodeName.toUpperCase() === 'LABEL' &&
21+
labels.indexOf(parent) === -1
22+
) {
2023
labels.push(parent);
2124
}
2225
parent = parent.parentNode;

lib/checks/navigation/heading-order.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (ariaHeadingLevel !== null) {
55
return true;
66
}
77

8-
var headingLevel = node.tagName.match(/H(\d)/);
8+
var headingLevel = node.nodeName.toUpperCase().match(/H(\d)/);
99

1010
if (headingLevel) {
1111
this.data(parseInt(headingLevel[1], 10));

lib/checks/navigation/region.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function isRegion(virtualNode) {
4141
// Check if the node matches any of the CSS selectors of implicit landmarks
4242
return implicitLandmarks.some(implicitSelector => {
4343
let matches = axe.utils.matchesSelector(node, implicitSelector);
44-
if (node.tagName.toLowerCase() === 'form') {
44+
if (node.nodeName.toUpperCase() === 'FORM') {
4545
let titleAttr = node.getAttribute('title');
4646
let title =
4747
titleAttr && titleAttr.trim() !== ''

lib/checks/visibility/hidden-content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const whitelist = ['SCRIPT', 'HEAD', 'TITLE', 'NOSCRIPT', 'STYLE', 'TEMPLATE'];
22
if (
3-
!whitelist.includes(node.tagName.toUpperCase()) &&
3+
!whitelist.includes(node.nodeName.toUpperCase()) &&
44
axe.commons.dom.hasContentVirtual(virtualNode)
55
) {
66
const styles = window.getComputedStyle(node);

lib/commons/dom/is-visual-content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dom.isVisualContent = function(element) {
2626
return visualRoles.indexOf(role) !== -1;
2727
}
2828

29-
switch (element.tagName.toUpperCase()) {
29+
switch (element.nodeName.toUpperCase()) {
3030
case 'IMG':
3131
case 'IFRAME':
3232
case 'OBJECT':

0 commit comments

Comments
 (0)