mirror of
https://github.com/twbs/bootstrap.git
synced 2025-03-15 15:29:22 +01:00
use a class private getter to decouple same methods usage
This commit is contained in:
parent
75b2934596
commit
c4e189df40
@ -19,7 +19,6 @@ const NAME = 'popover'
|
|||||||
const DATA_KEY = 'bs.popover'
|
const DATA_KEY = 'bs.popover'
|
||||||
const EVENT_KEY = `.${DATA_KEY}`
|
const EVENT_KEY = `.${DATA_KEY}`
|
||||||
const CLASS_PREFIX = 'bs-popover'
|
const CLASS_PREFIX = 'bs-popover'
|
||||||
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
|
|
||||||
|
|
||||||
const Default = {
|
const Default = {
|
||||||
...Tooltip.Default,
|
...Tooltip.Default,
|
||||||
@ -124,21 +123,12 @@ class Popover extends Tooltip {
|
|||||||
|
|
||||||
// Private
|
// Private
|
||||||
|
|
||||||
_addAttachmentClass(attachment) {
|
|
||||||
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
_getContent() {
|
_getContent() {
|
||||||
return this._element.getAttribute('data-bs-content') || this._config.content
|
return this._element.getAttribute('data-bs-content') || this._config.content
|
||||||
}
|
}
|
||||||
|
|
||||||
_cleanTipClass() {
|
_getBasicClassPrefix() {
|
||||||
const tip = this.getTipElement()
|
return CLASS_PREFIX
|
||||||
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
|
|
||||||
if (tabClass !== null && tabClass.length > 0) {
|
|
||||||
tabClass.map(token => token.trim())
|
|
||||||
.forEach(tClass => tip.classList.remove(tClass))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
@ -37,7 +37,6 @@ const NAME = 'tooltip'
|
|||||||
const DATA_KEY = 'bs.tooltip'
|
const DATA_KEY = 'bs.tooltip'
|
||||||
const EVENT_KEY = `.${DATA_KEY}`
|
const EVENT_KEY = `.${DATA_KEY}`
|
||||||
const CLASS_PREFIX = 'bs-tooltip'
|
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 DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn'])
|
||||||
|
|
||||||
const DefaultType = {
|
const DefaultType = {
|
||||||
@ -514,7 +513,7 @@ class Tooltip extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_addAttachmentClass(attachment) {
|
_addAttachmentClass(attachment) {
|
||||||
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`)
|
this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
_getAttachment(placement) {
|
_getAttachment(placement) {
|
||||||
@ -699,13 +698,18 @@ class Tooltip extends BaseComponent {
|
|||||||
|
|
||||||
_cleanTipClass() {
|
_cleanTipClass() {
|
||||||
const tip = this.getTipElement()
|
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) {
|
if (tabClass !== null && tabClass.length > 0) {
|
||||||
tabClass.map(token => token.trim())
|
tabClass.map(token => token.trim())
|
||||||
.forEach(tClass => tip.classList.remove(tClass))
|
.forEach(tClass => tip.classList.remove(tClass))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getBasicClassPrefix() {
|
||||||
|
return CLASS_PREFIX
|
||||||
|
}
|
||||||
|
|
||||||
_handlePopperPlacementChange(popperData) {
|
_handlePopperPlacementChange(popperData) {
|
||||||
const { state } = popperData
|
const { state } = popperData
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user