mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 09:28:26 -04:00
Handle textbox without existing aria-described-by
jQuery.attr returns `undefined` if an element does not have an attribute. We want an empty string, rather than the default of coercing `undefined` to the string `'undefined'`.
This commit is contained in:
@@ -48,7 +48,14 @@
|
|||||||
.attr('id', id);
|
.attr('id', id);
|
||||||
|
|
||||||
this.$textbox
|
this.$textbox
|
||||||
.attr('aria-described-by', this.$textbox.attr('aria-described-by') + ' ' + id)
|
.attr(
|
||||||
|
'aria-described-by',
|
||||||
|
(
|
||||||
|
this.$textbox.attr('aria-described-by') || ''
|
||||||
|
) + (
|
||||||
|
this.$textbox.attr('aria-described-by') ? ' ' : ''
|
||||||
|
) + id
|
||||||
|
)
|
||||||
.on('input', throttle(this.update, 150))
|
.on('input', throttle(this.update, 150))
|
||||||
.trigger('input');
|
.trigger('input');
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,20 @@ describe('Update content', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("It should handle a textarea without an aria-described-by attribute", () => {
|
||||||
|
|
||||||
|
document.getElementById('template_content').removeAttribute('aria-described-by');
|
||||||
|
|
||||||
|
window.GOVUK.modules.start();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
document.getElementById('template_content').getAttribute('aria-described-by')
|
||||||
|
).toEqual(
|
||||||
|
"update-status"
|
||||||
|
);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
test("It should make requests to the URL specified in the data-updates-url attribute", () => {
|
test("It should make requests to the URL specified in the data-updates-url attribute", () => {
|
||||||
|
|
||||||
window.GOVUK.modules.start();
|
window.GOVUK.modules.start();
|
||||||
|
|||||||
Reference in New Issue
Block a user