aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorRohit Sharma <[email protected]>2021-01-14 01:43:30 +0530
committerGitHub <[email protected]>2021-01-13 22:13:30 +0200
commitc9cd741aff6acedaedfd2cf96df06a8b46b4826a (patch)
tree01d31a107078fe4f30879e162df8e45336d5f4ef /js/src
parente34481b6eb5c7b9db35911f428cb96af6947741e (diff)
downloadbootstrap-c9cd741aff6acedaedfd2cf96df06a8b46b4826a.tar.xz
bootstrap-c9cd741aff6acedaedfd2cf96df06a8b46b4826a.zip
Throw a `TypeError` instead of the generic `Error` (#32585)
* Change from Error to TypeError * Convert the `NAME` to upper case to make the consistency in the error message * Update the remaining tests to be stricter Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/src')
-rw-r--r--js/src/dropdown.js2
-rw-r--r--js/src/util/index.js9
2 files changed, 5 insertions, 6 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 008294e9b..bada537c9 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -263,7 +263,7 @@ class Dropdown extends BaseComponent {
typeof config.reference.getBoundingClientRect !== 'function'
) {
// Popper virtual elements require a getBoundingClientRect method
- throw new Error(`${NAME}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`)
+ throw new TypeError(`${NAME.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`)
}
return config
diff --git a/js/src/util/index.js b/js/src/util/index.js
index 9ccad1cbb..22d0a578b 100644
--- a/js/src/util/index.js
+++ b/js/src/util/index.js
@@ -111,15 +111,14 @@ const typeCheckConfig = (componentName, config, configTypes) => {
Object.keys(configTypes).forEach(property => {
const expectedTypes = configTypes[property]
const value = config[property]
- const valueType = value && isElement(value) ?
- 'element' :
- toType(value)
+ const valueType = value && isElement(value) ? 'element' : toType(value)
if (!new RegExp(expectedTypes).test(valueType)) {
- throw new Error(
+ throw new TypeError(
`${componentName.toUpperCase()}: ` +
`Option "${property}" provided type "${valueType}" ` +
- `but expected type "${expectedTypes}".`)
+ `but expected type "${expectedTypes}".`
+ )
}
})
}