]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
util: change `isRTL` to a function (#32446)
authorXhmikosR <xhmikosr@gmail.com>
Tue, 16 Feb 2021 08:14:05 +0000 (10:14 +0200)
committerGitHub <noreply@github.com>
Tue, 16 Feb 2021 08:14:05 +0000 (10:14 +0200)
This allows the bundler to tree-shake the function.

js/src/carousel.js
js/src/dropdown.js
js/src/modal.js
js/src/tooltip.js
js/src/util/index.js

index 17814d42de280bcaa320a86757432dbc03da6099..75f8a4da79838fab9fbdccf9fe693106d0ecb865 100644 (file)
@@ -253,7 +253,7 @@ class Carousel extends BaseComponent {
 
     // swipe left
     if (direction > 0) {
-      if (isRTL) {
+      if (isRTL()) {
         this.next()
       } else {
         this.prev()
@@ -262,7 +262,7 @@ class Carousel extends BaseComponent {
 
     // swipe right
     if (direction < 0) {
-      if (isRTL) {
+      if (isRTL()) {
         this.prev()
       } else {
         this.next()
@@ -350,14 +350,14 @@ class Carousel extends BaseComponent {
 
     if (event.key === ARROW_LEFT_KEY) {
       event.preventDefault()
-      if (isRTL) {
+      if (isRTL()) {
         this.next()
       } else {
         this.prev()
       }
     } else if (event.key === ARROW_RIGHT_KEY) {
       event.preventDefault()
-      if (isRTL) {
+      if (isRTL()) {
         this.prev()
       } else {
         this.next()
index 97c0f50520f9ebe7f98543ac83b0da2e3e440a27..590c748012c9d134a3be426510e7d785f25132ac 100644 (file)
@@ -64,12 +64,12 @@ const SELECTOR_MENU = '.dropdown-menu'
 const SELECTOR_NAVBAR_NAV = '.navbar-nav'
 const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
 
-const PLACEMENT_TOP = isRTL ? 'top-end' : 'top-start'
-const PLACEMENT_TOPEND = isRTL ? 'top-start' : 'top-end'
-const PLACEMENT_BOTTOM = isRTL ? 'bottom-end' : 'bottom-start'
-const PLACEMENT_BOTTOMEND = isRTL ? 'bottom-start' : 'bottom-end'
-const PLACEMENT_RIGHT = isRTL ? 'left-start' : 'right-start'
-const PLACEMENT_LEFT = isRTL ? 'right-start' : 'left-start'
+const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start'
+const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end'
+const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start'
+const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end'
+const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'
+const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start'
 
 const Default = {
   offset: [0, 2],
index 36972ce66ca0d45f89f698870467d272d9998831..79a2f143a38b092a46a574a3950c31246a2618de 100644 (file)
@@ -431,14 +431,13 @@ class Modal extends BaseComponent {
   // ----------------------------------------------------------------------
 
   _adjustDialog() {
-    const isModalOverflowing =
-      this._element.scrollHeight > document.documentElement.clientHeight
+    const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
 
-    if ((!this._isBodyOverflowing && isModalOverflowing && !isRTL) || (this._isBodyOverflowing && !isModalOverflowing && isRTL)) {
+    if ((!this._isBodyOverflowing && isModalOverflowing && !isRTL()) || (this._isBodyOverflowing && !isModalOverflowing && isRTL())) {
       this._element.style.paddingLeft = `${this._scrollbarWidth}px`
     }
 
-    if ((this._isBodyOverflowing && !isModalOverflowing && !isRTL) || (!this._isBodyOverflowing && isModalOverflowing && isRTL)) {
+    if ((this._isBodyOverflowing && !isModalOverflowing && !isRTL()) || (!this._isBodyOverflowing && isModalOverflowing && isRTL())) {
       this._element.style.paddingRight = `${this._scrollbarWidth}px`
     }
   }
index c0f8b7c1e8fa0e9b222268f2a89b100753fa2781..d35b5e0ab102cd04e9f461435a8e8d2abbbc8da1 100644 (file)
@@ -64,9 +64,9 @@ const DefaultType = {
 const AttachmentMap = {
   AUTO: 'auto',
   TOP: 'top',
-  RIGHT: isRTL ? 'left' : 'right',
+  RIGHT: isRTL() ? 'left' : 'right',
   BOTTOM: 'bottom',
-  LEFT: isRTL ? 'right' : 'left'
+  LEFT: isRTL() ? 'right' : 'left'
 }
 
 const Default = {
@@ -563,8 +563,7 @@ class Tooltip extends BaseComponent {
 
     triggers.forEach(trigger => {
       if (trigger === 'click') {
-        EventHandler.on(this._element, this.constructor.Event.CLICK, this.config.selector, event => this.toggle(event)
-        )
+        EventHandler.on(this._element, this.constructor.Event.CLICK, this.config.selector, event => this.toggle(event))
       } else if (trigger !== TRIGGER_MANUAL) {
         const eventIn = trigger === TRIGGER_HOVER ?
           this.constructor.Event.MOUSEENTER :
index c7856fa62a11e9894c3610e766dfe43dbfbe9beb..ae3cd2ac00a94ee7faf727052719996620303ef3 100644 (file)
@@ -198,7 +198,7 @@ const onDOMContentLoaded = callback => {
   }
 }
 
-const isRTL = document.documentElement.dir === 'rtl'
+const isRTL = () => document.documentElement.dir === 'rtl'
 
 const defineJQueryPlugin = (name, plugin) => {
   onDOMContentLoaded(() => {