2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-17 19:21:23 +03:00

Extract Component config functionality to a separate class (#33872)

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
GeoSot
2021-12-10 18:18:18 +02:00
committed by GitHub
parent 68f226750d
commit 886b940796
18 changed files with 283 additions and 240 deletions
+1 -15
View File
@@ -123,20 +123,6 @@ const getElement = object => {
return null
}
const typeCheckConfig = (componentName, config, configTypes) => {
for (const property of Object.keys(configTypes)) {
const expectedTypes = configTypes[property]
const value = config[property]
const valueType = value && isElement(value) ? 'element' : toType(value)
if (!new RegExp(expectedTypes).test(valueType)) {
throw new TypeError(
`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`
)
}
}
}
const isVisible = element => {
if (!isElement(element) || element.getClientRects().length === 0) {
return false
@@ -327,5 +313,5 @@ export {
onDOMContentLoaded,
reflow,
triggerTransitionEnd,
typeCheckConfig
toType
}