aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorRohit Sharma <[email protected]>2020-11-25 12:46:22 +0530
committerGitHub <[email protected]>2020-11-25 09:16:22 +0200
commitc348ad4a941cf309de9073d5db02814453469369 (patch)
treee674c6730548e34c64576f521c4fdce486a84a37 /js/src
parentd61f506a5fdb7fcf4ab02fa9b748a8ac1c2dd78d (diff)
downloadbootstrap-c348ad4a941cf309de9073d5db02814453469369.tar.xz
bootstrap-c348ad4a941cf309de9073d5db02814453469369.zip
Ability to add custom class in tooltip/popover (#32217)
Porting of #31834 to main. Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/src')
-rw-r--r--js/src/tooltip.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index b2495a3e1..368e04b30 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -54,6 +54,7 @@ const DefaultType = {
container: '(string|element|boolean)',
fallbackPlacement: '(string|array)',
boundary: '(string|element)',
+ customClass: '(string|function)',
sanitize: 'boolean',
sanitizeFn: '(null|function)',
allowList: 'object',
@@ -83,6 +84,7 @@ const Default = {
container: false,
fallbackPlacement: 'flip',
boundary: 'scrollParent',
+ customClass: '',
sanitize: true,
sanitizeFn: null,
allowList: DefaultAllowlist,
@@ -296,6 +298,11 @@ class Tooltip {
tip.classList.add(CLASS_NAME_SHOW)
+ const customClass = typeof this.config.customClass === 'function' ? this.config.customClass() : this.config.customClass
+ if (customClass) {
+ tip.classList.add(...customClass.split(' '))
+ }
+
// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS