]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
src/tooltip.js Optimization
authorДилян Палаузов <git-dpa@aegee.org>
Thu, 27 Jan 2022 08:43:27 +0000 (10:43 +0200)
committerMark Otto <otto@github.com>
Fri, 25 Feb 2022 17:01:49 +0000 (09:01 -0800)
Util.findShadowRoot() returns either null or an object.

It cannot return falsy, which allows this optimization.

js/src/tooltip.js

index 5cf56ce6e39af84ed165dd663b59d7c822f2fd7b..db626048f67bf56f91080b7b9157c09204f08643 100644 (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