}
function findHandler(events, handler, delegationSelector = null) {
- const uidEventList = Object.keys(events)
-
- for (const uidEvent of uidEventList) {
+ for (const uidEvent of Object.keys(events)) {
const event = events[uidEvent]
if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
const delegation = typeof handler === 'string'
const originalHandler = delegation ? delegationFn : handler
let typeEvent = getTypeEvent(originalTypeEvent)
- const isNative = nativeEvents.has(typeEvent)
- if (!isNative) {
+ if (!nativeEvents.has(typeEvent)) {
typeEvent = originalTypeEvent
}
return
}
- const { classList, scrollHeight, style } = this._element
- const isModalOverflowing = scrollHeight > document.documentElement.clientHeight
- const initialOverflowY = style.overflowY
+ const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
+ const initialOverflowY = this._element.style.overflowY
// return if the following background transition hasn't yet completed
- if (initialOverflowY === 'hidden' || classList.contains(CLASS_NAME_STATIC)) {
+ if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) {
return
}
if (!isModalOverflowing) {
- style.overflowY = 'hidden'
+ this._element.style.overflowY = 'hidden'
}
- classList.add(CLASS_NAME_STATIC)
+ this._element.classList.add(CLASS_NAME_STATIC)
this._queueCallback(() => {
- classList.remove(CLASS_NAME_STATIC)
+ this._element.classList.remove(CLASS_NAME_STATIC)
this._queueCallback(() => {
- style.overflowY = initialOverflowY
+ this._element.style.overflowY = initialOverflowY
}, this._dialog)
}, this._dialog)
// Public
activate() {
- const { trapElement, autofocus } = this._config
-
if (this._isActive) {
return
}
- if (autofocus) {
- trapElement.focus()
+ if (this._config.autofocus) {
+ this._config.trapElement.focus()
}
EventHandler.off(document, EVENT_KEY) // guard against infinite focus loop
// Private
_handleFocusin(event) {
- const { target } = event
const { trapElement } = this._config
- if (target === document || target === trapElement || trapElement.contains(target)) {
+ if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) {
return
}