Use the `switch` statement instead of `if`

This commit is contained in:
Rohit Sharma 2021-06-09 15:02:45 +05:30 committed by Mark Otto
parent f94f497ad5
commit 5967ebd906
1 changed files with 55 additions and 64 deletions

View File

@ -59,39 +59,26 @@ const defaultPluginConfig = {
}
const getConfigByPluginKey = pluginKey => {
if (
pluginKey === 'Data' ||
pluginKey === 'Manipulator' ||
pluginKey === 'EventHandler' ||
pluginKey === 'SelectorEngine' ||
pluginKey === 'Util' ||
pluginKey === 'Sanitizer' ||
pluginKey === 'Backdrop'
) {
return {
external: []
}
}
if (pluginKey === 'Alert' || pluginKey === 'Tab' || pluginKey === 'Offcanvas') {
switch (pluginKey) {
case 'Alert':
case 'Offcanvas':
case 'Tab':
return defaultPluginConfig
}
if (
pluginKey === 'Base' ||
pluginKey === 'Button' ||
pluginKey === 'Carousel' ||
pluginKey === 'Collapse' ||
pluginKey === 'Modal' ||
pluginKey === 'ScrollSpy'
) {
case 'Base':
case 'Button':
case 'Carousel':
case 'Collapse':
case 'Modal':
case 'ScrollSpy': {
const config = Object.assign(defaultPluginConfig)
config.external.push(bsPlugins.Manipulator)
config.globals[bsPlugins.Manipulator] = 'Manipulator'
return config
}
if (pluginKey === 'Dropdown' || pluginKey === 'Tooltip') {
case 'Dropdown':
case 'Tooltip': {
const config = Object.assign(defaultPluginConfig)
config.external.push(bsPlugins.Manipulator, '@popperjs/core')
config.globals[bsPlugins.Manipulator] = 'Manipulator'
@ -99,7 +86,7 @@ const getConfigByPluginKey = pluginKey => {
return config
}
if (pluginKey === 'Popover') {
case 'Popover':
return {
external: [
bsPlugins.Data,
@ -112,9 +99,8 @@ const getConfigByPluginKey = pluginKey => {
[bsPlugins.Tooltip]: 'Tooltip'
}
}
}
if (pluginKey === 'Toast') {
case 'Toast':
return {
external: [
bsPlugins.Data,
@ -129,6 +115,11 @@ const getConfigByPluginKey = pluginKey => {
[bsPlugins.Manipulator]: 'Manipulator'
}
}
default:
return {
external: []
}
}
}