Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2021-02-16 11:14:05 +0300
committerGitHub <noreply@github.com>2021-02-16 11:14:05 +0300
commit92434fa30f38178ba6fd8f3a7d66828eec0783e0 (patch)
treeaa15308033b6f15dbb095f5445022c9c599e4910 /js
parent3602828a9001298fcfb6638041fc300f9e677bcb (diff)
util: change `isRTL` to a function (#32446)
This allows the bundler to tree-shake the function.
Diffstat (limited to 'js')
-rw-r--r--js/src/carousel.js8
-rw-r--r--js/src/dropdown.js12
-rw-r--r--js/src/modal.js7
-rw-r--r--js/src/tooltip.js7
-rw-r--r--js/src/util/index.js2
5 files changed, 17 insertions, 19 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 17814d42de..75f8a4da79 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -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()
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 97c0f50520..590c748012 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -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],
diff --git a/js/src/modal.js b/js/src/modal.js
index 36972ce66c..79a2f143a3 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -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`
}
}
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index c0f8b7c1e8..d35b5e0ab1 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -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 :
diff --git a/js/src/util/index.js b/js/src/util/index.js
index c7856fa62a..ae3cd2ac00 100644
--- a/js/src/util/index.js
+++ b/js/src/util/index.js
@@ -198,7 +198,7 @@ const onDOMContentLoaded = callback => {
}
}
-const isRTL = document.documentElement.dir === 'rtl'
+const isRTL = () => document.documentElement.dir === 'rtl'
const defineJQueryPlugin = (name, plugin) => {
onDOMContentLoaded(() => {