},
{
"path": "./dist/js/bootstrap.bundle.js",
- "maxSize": "42.75 kB"
+ "maxSize": "43.0 kB"
},
{
"path": "./dist/js/bootstrap.bundle.min.js",
},
{
"path": "./dist/js/bootstrap.esm.js",
- "maxSize": "27.5 kB"
+ "maxSize": "27.75 kB"
},
{
"path": "./dist/js/bootstrap.esm.min.js",
const EVENT_SHOW = `show${EVENT_KEY}`
const EVENT_SHOWN = `shown${EVENT_KEY}`
const EVENT_RESIZE = `resize${EVENT_KEY}`
+const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
// Private
_initializeBackDrop() {
- const clickCallback = () => {
- if (this._config.backdrop === 'static') {
- this._triggerBackdropTransition()
- return
- }
-
- this.hide()
- }
-
- // 'static' option will be translated to true, and booleans will keep their value
- const isVisible = Boolean(this._config.backdrop)
-
return new Backdrop({
- isVisible,
- isAnimated: this._isAnimated(),
- clickCallback: isVisible ? clickCallback : null
+ isVisible: Boolean(this._config.backdrop), // 'static' option will be translated to true, and booleans will keep their value,
+ isAnimated: this._isAnimated()
})
}
this._adjustDialog()
}
})
+
+ EventHandler.on(this._element, EVENT_CLICK_DISMISS, event => {
+ if (event.target !== event.currentTarget) { // click is inside modal-dialog
+ return
+ }
+
+ if (this._config.backdrop === 'static') {
+ this._triggerBackdropTransition()
+ return
+ }
+
+ if (this._config.backdrop) {
+ this.hide()
+ }
+ })
}
_hideModal() {
modalEl.addEventListener('shown.bs.modal', () => {
const spy = spyOn(modal, '_queueCallback').and.callThrough()
- const mouseOverEvent = createEvent('mousedown')
- const backdrop = document.querySelector('.modal-backdrop')
-
- backdrop.dispatchEvent(mouseOverEvent)
- backdrop.dispatchEvent(mouseOverEvent)
+ modalEl.click()
+ modalEl.click()
setTimeout(() => {
expect(spy).toHaveBeenCalledTimes(1)
const modalEl = fixtureEl.querySelector('.modal')
const modal = new Modal(modalEl)
modalEl.addEventListener('shown.bs.modal', () => {
- const mouseOverEvent = createEvent('mousedown')
- document.querySelector('.modal-backdrop').dispatchEvent(mouseOverEvent)
+ modalEl.click()
})
modalEl.addEventListener('hidden.bs.modal', () => {