aboutsummaryrefslogtreecommitdiff
path: root/js/src/util
diff options
context:
space:
mode:
authorGeoSot <[email protected]>2022-10-07 15:25:00 +0300
committerGitHub <[email protected]>2022-10-07 15:25:00 +0300
commit4cb046a6b8b37a0f328fa5b86fbd573ca3f0dc33 (patch)
treee4ed791f3cfbe938308095ef1f4d123c72a323a2 /js/src/util
parent708a3a0e398f6c01f00283941cd6a4aca9f66322 (diff)
downloadbootstrap-4cb046a6b8b37a0f328fa5b86fbd573ca3f0dc33.tar.xz
bootstrap-4cb046a6b8b37a0f328fa5b86fbd573ca3f0dc33.zip
Boost `execute` function, being able to handle arguments (#36652)
Diffstat (limited to 'js/src/util')
-rw-r--r--js/src/util/index.js6
-rw-r--r--js/src/util/template-factory.js4
2 files changed, 4 insertions, 6 deletions
diff --git a/js/src/util/index.js b/js/src/util/index.js
index 7c2411665..ad99f85ed 100644
--- a/js/src/util/index.js
+++ b/js/src/util/index.js
@@ -249,10 +249,8 @@ const defineJQueryPlugin = plugin => {
})
}
-const execute = callback => {
- if (typeof callback === 'function') {
- callback()
- }
+const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
+ return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue
}
const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
diff --git a/js/src/util/template-factory.js b/js/src/util/template-factory.js
index c6d52a50d..16ec6c28d 100644
--- a/js/src/util/template-factory.js
+++ b/js/src/util/template-factory.js
@@ -6,7 +6,7 @@
*/
import { DefaultAllowlist, sanitizeHtml } from './sanitizer'
-import { getElement, isElement } from '../util/index'
+import { execute, getElement, isElement } from '../util/index'
import SelectorEngine from '../dom/selector-engine'
import Config from './config'
@@ -143,7 +143,7 @@ class TemplateFactory extends Config {
}
_resolvePossibleFunction(arg) {
- return typeof arg === 'function' ? arg(this) : arg
+ return execute(arg, [this])
}
_putElementInTemplate(element, templateElement) {