Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid IE problems by using nodeName instead of tagName #1219

Merged
merged 3 commits into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checks/aria/required-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/checks/aria/valid-scrollable-semantics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/checks/keyboard/landmark-is-top-level.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 4 additions & 1 deletion lib/checks/label/multiple-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/checks/navigation/heading-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (ariaHeadingLevel !== null) {
return true;
}

var headingLevel = node.tagName.match(/H(\d)/);
var headingLevel = node.nodeName.match(/H(\d)/);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need toUpperCase() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to leave this on as is (no need to uppercase).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree. In xhtml nodeName is lower case, which means this won't match.


if (headingLevel) {
this.data(parseInt(headingLevel[1], 10));
Expand Down
2 changes: 1 addition & 1 deletion lib/checks/navigation/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() !== ''
Expand Down
2 changes: 1 addition & 1 deletion lib/checks/visibility/hidden-content.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/commons/dom/is-visual-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down