mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-26 06:44:35 +02:00
add simple type checker implementation
This commit is contained in:
@@ -33,6 +33,13 @@ const Modal = (($) => {
|
||||
show : true
|
||||
}
|
||||
|
||||
const DefaultType = {
|
||||
backdrop : '(boolean|string)',
|
||||
keyboard : 'boolean',
|
||||
focus : 'boolean',
|
||||
show : 'boolean'
|
||||
}
|
||||
|
||||
const Event = {
|
||||
HIDE : `hide${EVENT_KEY}`,
|
||||
HIDDEN : `hidden${EVENT_KEY}`,
|
||||
@@ -71,7 +78,7 @@ const Modal = (($) => {
|
||||
class Modal {
|
||||
|
||||
constructor(element, config) {
|
||||
this._config = config
|
||||
this._config = this._getConfig(config)
|
||||
this._element = element
|
||||
this._dialog = $(element).find(Selector.DIALOG)[0]
|
||||
this._backdrop = null
|
||||
@@ -198,6 +205,12 @@ const Modal = (($) => {
|
||||
|
||||
// private
|
||||
|
||||
_getConfig(config) {
|
||||
config = $.extend({}, Default, config)
|
||||
Util.typeCheckConfig(NAME, config, DefaultType)
|
||||
return config
|
||||
}
|
||||
|
||||
_showElement(relatedTarget) {
|
||||
let transition = Util.supportsTransitionEnd() &&
|
||||
$(this._element).hasClass(ClassName.FADE)
|
||||
|
Reference in New Issue
Block a user