0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-28 20:52:21 +01:00

Re-set tooltip title, on disposal (#36751)

fix(reg): Re-set tooltip title, on disposal
This commit is contained in:
GeoSot 2022-07-27 17:40:05 +03:00 committed by GitHub
parent 44c9c8df8d
commit dfae892801
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -185,6 +185,10 @@ class Tooltip extends BaseComponent {
this.tip.remove()
}
if (this._config.originalTitle) {
this._element.setAttribute('title', this._config.originalTitle)
}
this._disposePopper()
super.dispose()
}

View File

@ -419,6 +419,25 @@ describe('Tooltip', () => {
tooltip.show()
})
})
it('should destroy a tooltip and reset it\'s initial title', () => {
fixtureEl.innerHTML = [
'<span id="tooltipWithTitle" rel="tooltip" title="tooltipTitle"></span>',
'<span id="tooltipWithoutTitle" rel="tooltip" data-bs-title="tooltipTitle"></span>'
].join('')
const tooltipWithTitleEl = fixtureEl.querySelector('#tooltipWithTitle')
const tooltip = new Tooltip('#tooltipWithTitle')
expect(tooltipWithTitleEl.getAttribute('title')).toBeNull()
tooltip.dispose()
expect(tooltipWithTitleEl.getAttribute('title')).toBe('tooltipTitle')
const tooltipWithoutTitleEl = fixtureEl.querySelector('#tooltipWithoutTitle')
const tooltip2 = new Tooltip('#tooltipWithTitle')
expect(tooltipWithoutTitleEl.getAttribute('title')).toBeNull()
tooltip2.dispose()
expect(tooltipWithoutTitleEl.getAttribute('title')).toBeNull()
})
})
describe('show', () => {