Fix TypeError when Bootstrap is included in head (#32024)
* extend jquery after domContentLoaded event is fired * add unittest for util onDOMContentLoaded * wait for trigger jquery event after domContentLoaded * remove domcontentready from eventHandler * move istanbul ignore statements to correct line Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
parent
3a5f9f5cf0
commit
c21506d499
14 changed files with 184 additions and 126 deletions
|
|
@ -394,4 +394,23 @@ describe('Util', () => {
|
|||
expect(Util.getjQuery()).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('onDOMContentLoaded', () => {
|
||||
it('should execute callback when DOMContentLoaded is fired', () => {
|
||||
const spy = jasmine.createSpy()
|
||||
spyOnProperty(document, 'readyState').and.returnValue('loading')
|
||||
Util.onDOMContentLoaded(spy)
|
||||
window.document.dispatchEvent(new Event('DOMContentLoaded', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
}))
|
||||
expect(spy).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should execute callback if readyState is not "loading"', () => {
|
||||
const spy = jasmine.createSpy()
|
||||
Util.onDOMContentLoaded(spy)
|
||||
expect(spy).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue