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:
parent
44c9c8df8d
commit
dfae892801
@ -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()
|
||||
}
|
||||
|
@ -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', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user