Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially backport #32217 #32225

Merged
merged 2 commits into from Nov 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions js/src/tooltip.js
Expand Up @@ -286,7 +286,7 @@ class Tooltip {
this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment))

$(tip).addClass(CLASS_NAME_SHOW)
$(tip).addClass(this._getCustomClass())
$(tip).addClass(this.config.customClass)

// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
Expand Down Expand Up @@ -734,10 +734,6 @@ class Tooltip {
this.config.animation = initConfigAnimation
}

_getCustomClass() {
return this.element.getAttribute('data-custom-class') || this.config.customClass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this not needed? 😵

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the customClass will be in the configuration already, even if it is provided in the data attributes 🤔

bootstrap/js/src/tooltip.js

Lines 660 to 664 in 2d8c02e

config = {
...this.constructor.Default,
...dataAttributes,
...(typeof config === 'object' && config ? config : {})
}

Ref: #32217 (comment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And jQuery's addClass() method will handle it, either this.config.customClass is a function or a class name (Even it is a blank string)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep good catch 👌

}

// Static

static _jQueryInterface(config) {
Expand Down