mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-26 06:44:35 +02:00
Extract Component config functionality to a separate class (#33872)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -5,16 +5,8 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import {
|
||||
defineJQueryPlugin,
|
||||
getElementFromSelector,
|
||||
isRTL,
|
||||
isVisible,
|
||||
reflow,
|
||||
typeCheckConfig
|
||||
} from './util/index'
|
||||
import { defineJQueryPlugin, getElementFromSelector, isRTL, isVisible, reflow } from './util/index'
|
||||
import EventHandler from './dom/event-handler'
|
||||
import Manipulator from './dom/manipulator'
|
||||
import SelectorEngine from './dom/selector-engine'
|
||||
import ScrollBarHelper from './util/scrollbar'
|
||||
import BaseComponent from './base-component'
|
||||
@@ -70,9 +62,8 @@ const DefaultType = {
|
||||
|
||||
class Modal extends BaseComponent {
|
||||
constructor(element, config) {
|
||||
super(element)
|
||||
super(element, config)
|
||||
|
||||
this._config = this._getConfig(config)
|
||||
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element)
|
||||
this._backdrop = this._initializeBackDrop()
|
||||
this._focustrap = this._initializeFocusTrap()
|
||||
@@ -86,6 +77,10 @@ class Modal extends BaseComponent {
|
||||
return Default
|
||||
}
|
||||
|
||||
static get DefaultType() {
|
||||
return DefaultType
|
||||
}
|
||||
|
||||
static get NAME() {
|
||||
return NAME
|
||||
}
|
||||
@@ -175,16 +170,6 @@ class Modal extends BaseComponent {
|
||||
})
|
||||
}
|
||||
|
||||
_getConfig(config) {
|
||||
config = {
|
||||
...Default,
|
||||
...Manipulator.getDataAttributes(this._element),
|
||||
...(typeof config === 'object' ? config : {})
|
||||
}
|
||||
typeCheckConfig(NAME, config, DefaultType)
|
||||
return config
|
||||
}
|
||||
|
||||
_showElement(relatedTarget) {
|
||||
// try to append dynamic modal
|
||||
if (!document.body.contains(this._element)) {
|
||||
|
Reference in New Issue
Block a user