-
Notifications
You must be signed in to change notification settings - Fork 643
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 accessibility issues identified by tool #5795
Changes from all commits
b1aef76
d35ca48
f7ac4c5
8764838
781afb7
4df30e3
1678baf
cec2e3c
1c7947e
0254ebe
279b122
66dcf5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,10 +50,48 @@ | |
} else { | ||
error.insertAfter(element); | ||
} | ||
}, | ||
showErrors: function (errorMap, errorList) { | ||
this.defaultShowErrors(); | ||
|
||
// By default, showErrors adds an aria-describedby attribute to every field that it validates, even if it finds no issues. | ||
// This is a problem, because the aria-describedby attribute will then link to an empty element. | ||
// This code removes the aria-describedby if the describing element is missing or empty. | ||
var i; | ||
for (i = 0; this.errorList[i]; i++) { | ||
removeInvalidAriaDescribedBy(this.errorList[i].element); | ||
} | ||
|
||
for (i = 0; this.successList[i]; i++) { | ||
removeInvalidAriaDescribedBy(this.successList[i]); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
function removeInvalidAriaDescribedBy(element) { | ||
var describedBy = element.getAttribute("aria-describedby"); | ||
if (!describedBy) { | ||
return; | ||
} | ||
|
||
var ids = describedBy.split(" ") | ||
.filter(function (describedById) { | ||
if (!describedById) { | ||
return false; | ||
} | ||
|
||
var describedByElement = $("#" + describedById); | ||
return describedByElement && describedByElement.text(); | ||
}); | ||
|
||
if (ids.length) { | ||
element.setAttribute("aria-describedby", ids.join(" ")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only call `setAttribute if the IDs set has changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
} else { | ||
element.removeAttribute("aria-describedby"); | ||
} | ||
} | ||
|
||
nuget.parseNumber = function (unparsedValue) { | ||
unparsedValue = ('' + unparsedValue).replace(/,/g, ''); | ||
var parsedValue = parseInt(unparsedValue); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jquery.validate
calls it whenever the state of our forms has changed. It adds validation error text to our forms when the content isn't correct. I'm using their default process and appending an additional step.