0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-20 17:54:23 +01:00

Accessibility update for tooltip.js

Update to the tooltip.js to add an aria-label attribute that contains the original title of the element, but only if the element doesn't have an existing aria-label attribute.

This is to address cases where screen readers are not capturing the aria-describedby attribute that is added when the tooltip is triggered.  This should also avoid a race condition between the screen reader and the appearance of the tooltip.
This commit is contained in:
Matty Williams 2019-05-29 21:48:59 +03:00 committed by XhmikosR
parent af57444405
commit b0372bb658

View File

@ -584,6 +584,10 @@ class Tooltip extends BaseComponent {
if (title || originalTitleType !== 'string') {
this._element.setAttribute('data-bs-original-title', title || '')
if (!this._element.getAttribute('aria-label') && !this._element.textContent) {
this._element.setAttribute('aria-label', this._element.getAttribute('title') || '')
}
this._element.setAttribute('title', '')
}
}