mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-12 08:34:08 +02:00
Fix event handler removal in dropdown/carousel dispose (#33000)
* Fix event handler removal in carousel dispose * Fix event handler removal in dropdown dispose * Test event handlers in scrollspy dispose * Test event handlers in toast dispose * Test event handlers in tooltip dispose Co-authored-by: XhmikosR <xhmikosr@gmail.com> Co-authored-by: Rohit Sharma <rohit2sharma95@gmail.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import ScrollSpy from '../../src/scrollspy'
|
||||
import Manipulator from '../../src/dom/manipulator'
|
||||
import EventHandler from '../../src/dom/event-handler'
|
||||
|
||||
/** Test helpers */
|
||||
import { getFixture, clearFixture, createEvent, jQueryMock } from '../helpers/fixture'
|
||||
@@ -560,14 +559,18 @@ describe('ScrollSpy', () => {
|
||||
|
||||
describe('dispose', () => {
|
||||
it('should dispose a scrollspy', () => {
|
||||
spyOn(EventHandler, 'off')
|
||||
fixtureEl.innerHTML = '<div style="display: none;"></div>'
|
||||
|
||||
const divEl = fixtureEl.querySelector('div')
|
||||
spyOn(divEl, 'addEventListener').and.callThrough()
|
||||
spyOn(divEl, 'removeEventListener').and.callThrough()
|
||||
|
||||
const scrollSpy = new ScrollSpy(divEl)
|
||||
expect(divEl.addEventListener).toHaveBeenCalledWith('scroll', jasmine.any(Function), jasmine.any(Boolean))
|
||||
|
||||
scrollSpy.dispose()
|
||||
expect(EventHandler.off).toHaveBeenCalledWith(divEl, '.bs.scrollspy')
|
||||
|
||||
expect(divEl.removeEventListener).toHaveBeenCalledWith('scroll', jasmine.any(Function), jasmine.any(Boolean))
|
||||
})
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user