0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

src/tooltip.js Optimization

Util.findShadowRoot() returns either null or an object.

It cannot return falsy, which allows this optimization.
This commit is contained in:
Дилян Палаузов 2022-01-27 10:43:27 +02:00 committed by Mark Otto
parent 28d9aaf670
commit e4b62a920a

View File

@ -199,9 +199,7 @@ class Tooltip extends BaseComponent {
const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW))
const shadowRoot = findShadowRoot(this._element)
const isInTheDom = shadowRoot === null ?
this._element.ownerDocument.documentElement.contains(this._element) :
shadowRoot.contains(this._element)
const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element)
if (showEvent.defaultPrevented || !isInTheDom) {
return