aboutsummaryrefslogtreecommitdiff
path: root/js/src/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/util.js')
-rw-r--r--js/src/util.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/js/src/util.js b/js/src/util.js
index 3c0d02251..a75660014 100644
--- a/js/src/util.js
+++ b/js/src/util.js
@@ -1,11 +1,13 @@
+import $ from 'jquery'
+
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): util.js
+ * Bootstrap (v4.0.0-beta): util.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
-const Util = (($) => {
+const Util = (() => {
/**
@@ -30,10 +32,6 @@ const Util = (($) => {
return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}
- function isElement(obj) {
- return (obj[0] || obj).nodeType
- }
-
function getSpecialTransitionEndEvent() {
return {
bindType: transition.end,
@@ -42,7 +40,7 @@ const Util = (($) => {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params
}
- return undefined
+ return undefined // eslint-disable-line no-undefined
}
}
}
@@ -55,7 +53,7 @@ const Util = (($) => {
const el = document.createElement('bootstrap')
for (const name in TransitionEndEvent) {
- if (el.style[name] !== undefined) {
+ if (typeof el.style[name] !== 'undefined') {
return {
end: TransitionEndEvent[name]
}
@@ -117,7 +115,7 @@ const Util = (($) => {
}
try {
- const $selector = $(selector)
+ const $selector = $(document).find(selector)
return $selector.length > 0 ? selector : null
} catch (error) {
return null
@@ -136,12 +134,16 @@ const Util = (($) => {
return Boolean(transition)
},
+ isElement(obj) {
+ return (obj[0] || obj).nodeType
+ },
+
typeCheckConfig(componentName, config, configTypes) {
for (const property in configTypes) {
- if (configTypes.hasOwnProperty(property)) {
+ if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
const expectedTypes = configTypes[property]
const value = config[property]
- const valueType = value && isElement(value) ?
+ const valueType = value && Util.isElement(value) ?
'element' : toType(value)
if (!new RegExp(expectedTypes).test(valueType)) {
@@ -159,6 +161,6 @@ const Util = (($) => {
return Util
-})(jQuery)
+})($)
export default Util