diff options
author | GeoSot <geo.sotis@gmail.com> | 2021-06-10 10:48:35 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2021-07-22 17:20:38 +0300 |
commit | c4e189df40ffced65848d440e8e95892360445ba (patch) | |
tree | af7c73303561d4e530cc54d7daf0932351e2045e /js/src/tooltip.js | |
parent | 75b293459628d976f26347c64774b909be329336 (diff) |
use a class private getter to decouple same methods usage
Diffstat (limited to 'js/src/tooltip.js')
-rw-r--r-- | js/src/tooltip.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js index cd4a2878e0..cdc9b1e5d5 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -37,7 +37,6 @@ const NAME = 'tooltip' const DATA_KEY = 'bs.tooltip' const EVENT_KEY = `.${DATA_KEY}` const CLASS_PREFIX = 'bs-tooltip' -const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g') const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']) const DefaultType = { @@ -514,7 +513,7 @@ class Tooltip extends BaseComponent { } _addAttachmentClass(attachment) { - this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`) + this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`) } _getAttachment(placement) { @@ -699,13 +698,18 @@ class Tooltip extends BaseComponent { _cleanTipClass() { const tip = this.getTipElement() - const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX) + const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g') + const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex) if (tabClass !== null && tabClass.length > 0) { tabClass.map(token => token.trim()) .forEach(tClass => tip.classList.remove(tClass)) } } + _getBasicClassPrefix() { + return CLASS_PREFIX + } + _handlePopperPlacementChange(popperData) { const { state } = popperData |