mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-30 22:52:24 +01:00
Allow use of dispose/hide
methods on Tooltip & Popover from jQueryInterface, when component does not exists. (#33371)
This commit is contained in:
parent
de0b797ab2
commit
9e4f87ae8f
@ -149,10 +149,6 @@ class Popover extends Tooltip {
|
||||
let data = Data.get(this, DATA_KEY)
|
||||
const _config = typeof config === 'object' ? config : null
|
||||
|
||||
if (!data && /dispose|hide/.test(config)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
data = new Popover(this, _config)
|
||||
Data.set(this, DATA_KEY, data)
|
||||
|
@ -725,10 +725,6 @@ class Tooltip extends BaseComponent {
|
||||
let data = Data.get(this, DATA_KEY)
|
||||
const _config = typeof config === 'object' && config
|
||||
|
||||
if (!data && /dispose|hide/.test(config)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
data = new Tooltip(this, _config)
|
||||
}
|
||||
|
@ -266,21 +266,6 @@ describe('Popover', () => {
|
||||
|
||||
expect(popover.show).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should do nothing if dipose is called when a popover do not exist', () => {
|
||||
fixtureEl.innerHTML = '<a href="#" title="Popover" data-bs-content="https://twitter.com/getbootstrap">BS twitter</a>'
|
||||
|
||||
const popoverEl = fixtureEl.querySelector('a')
|
||||
|
||||
jQueryMock.fn.popover = Popover.jQueryInterface
|
||||
jQueryMock.elements = [popoverEl]
|
||||
|
||||
spyOn(Popover.prototype, 'dispose')
|
||||
|
||||
jQueryMock.fn.popover.call(jQueryMock, 'dispose')
|
||||
|
||||
expect(Popover.prototype.dispose).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('getInstance', () => {
|
||||
|
@ -1351,21 +1351,6 @@ describe('Tooltip', () => {
|
||||
expect(tooltip.show).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should do nothing when we call dispose or hide if there is no tooltip created', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
const div = fixtureEl.querySelector('div')
|
||||
|
||||
spyOn(Tooltip.prototype, 'dispose')
|
||||
|
||||
jQueryMock.fn.tooltip = Tooltip.jQueryInterface
|
||||
jQueryMock.elements = [div]
|
||||
|
||||
jQueryMock.fn.tooltip.call(jQueryMock, 'dispose')
|
||||
|
||||
expect(Tooltip.prototype.dispose).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should throw error on undefined method', () => {
|
||||
fixtureEl.innerHTML = '<div></div>'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user