1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-28 22:39:11 +02:00

add simple type checker implementation

This commit is contained in:
fat
2015-05-13 14:46:50 -07:00
parent c2ced2292a
commit eaab1def7a
25 changed files with 258 additions and 28 deletions

View File

@@ -30,6 +30,11 @@ const Collapse = (($) => {
parent : null
}
const DefaultType = {
toggle : 'boolean',
parent : '(string|null)'
}
const Event = {
SHOW : `show${EVENT_KEY}`,
SHOWN : `shown${EVENT_KEY}`,
@@ -67,7 +72,7 @@ const Collapse = (($) => {
constructor(element, config) {
this._isTransitioning = false
this._element = element
this._config = $.extend({}, Default, config)
this._config = this._getConfig(config)
this._triggerArray = $.makeArray($(
`[data-toggle="collapse"][href="#${element.id}"],` +
`[data-toggle="collapse"][data-target="#${element.id}"]`
@@ -259,6 +264,13 @@ const Collapse = (($) => {
// private
_getConfig(config) {
config = $.extend({}, Default, config)
config.toggle = !!config.toggle // coerce string values
Util.typeCheckConfig(NAME, config, DefaultType)
return config
}
_getDimension() {
let hasWidth = $(this._element).hasClass(Dimension.WIDTH)
return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT