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:
authorJohann-S <johann.servoire@gmail.com>2020-11-20 13:13:11 +0300
committerXhmikosR <xhmikosr@gmail.com>2020-11-29 21:58:26 +0300
commit9eb9d02084dc914e614e8844e3ffdee4d0a25126 (patch)
tree4c6722f81a9336921b85879aff41bc748ff12a2b /js
parent51a208f119522f8618801a6e61ff8d47cf89d4cf (diff)
add dispose in base component
Diffstat (limited to 'js')
-rw-r--r--js/src/alert.js5
-rw-r--r--js/src/base-component.js5
-rw-r--r--js/src/button.js5
-rw-r--r--js/src/carousel.js3
-rw-r--r--js/src/collapse.js4
-rw-r--r--js/src/dropdown.js3
-rw-r--r--js/src/modal.js5
-rw-r--r--js/src/scrollspy.js3
-rw-r--r--js/src/tab.js5
-rw-r--r--js/src/toast.js3
-rw-r--r--js/src/tooltip.js4
11 files changed, 13 insertions, 32 deletions
diff --git a/js/src/alert.js b/js/src/alert.js
index 6f4c0be8de..41cff54db2 100644
--- a/js/src/alert.js
+++ b/js/src/alert.js
@@ -69,11 +69,6 @@ class Alert extends BaseComponent {
this._removeElement(rootElement)
}
- dispose() {
- Data.removeData(this._element, DATA_KEY)
- this._element = null
- }
-
// Private
_getRootElement(element) {
diff --git a/js/src/base-component.js b/js/src/base-component.js
index a6c7f36bde..b1b85a4ee7 100644
--- a/js/src/base-component.js
+++ b/js/src/base-component.js
@@ -17,6 +17,11 @@ class BaseComponent {
Data.setData(element, this.constructor.DATA_KEY, this)
}
+ dispose() {
+ Data.removeData(this._element, this.constructor.DATA_KEY)
+ this._element = null
+ }
+
/** Static */
static getInstance(element) {
diff --git a/js/src/button.js b/js/src/button.js
index 2694e7b786..8b7c6c953c 100644
--- a/js/src/button.js
+++ b/js/src/button.js
@@ -52,11 +52,6 @@ class Button extends BaseComponent {
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE))
}
- dispose() {
- Data.removeData(this._element, DATA_KEY)
- this._element = null
- }
-
// Static
static jQueryInterface(config) {
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 6a035c9abd..35a1848f87 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -224,12 +224,11 @@ class Carousel extends BaseComponent {
}
dispose() {
+ super.dispose()
EventHandler.off(this._element, EVENT_KEY)
- Data.removeData(this._element, DATA_KEY)
this._items = null
this._config = null
- this._element = null
this._interval = null
this._isPaused = null
this._isSliding = null
diff --git a/js/src/collapse.js b/js/src/collapse.js
index c76426c7c4..9fb4d5edef 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -272,11 +272,9 @@ class Collapse extends BaseComponent {
}
dispose() {
- Data.removeData(this._element, DATA_KEY)
-
+ super.dispose()
this._config = null
this._parent = null
- this._element = null
this._triggerArray = null
this._isTransitioning = null
}
diff --git a/js/src/dropdown.js b/js/src/dropdown.js
index 16d35b911d..3641d9f9d2 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -235,9 +235,8 @@ class Dropdown extends BaseComponent {
}
dispose() {
- Data.removeData(this._element, DATA_KEY)
+ super.dispose()
EventHandler.off(this._element, EVENT_KEY)
- this._element = null
this._menu = null
if (this._popper) {
this._popper.destroy()
diff --git a/js/src/modal.js b/js/src/modal.js
index 1e7ce03469..449721caf7 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -207,6 +207,8 @@ class Modal extends BaseComponent {
[window, this._element, this._dialog]
.forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY))
+ super.dispose()
+
/**
* `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API`
* Do not move `document` in `htmlElements` array
@@ -214,10 +216,7 @@ class Modal extends BaseComponent {
*/
EventHandler.off(document, EVENT_FOCUSIN)
- Data.removeData(this._element, DATA_KEY)
-
this._config = null
- this._element = null
this._dialog = null
this._backdrop = null
this._isShown = null
diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js
index 6eb66f3b4a..0df00e8f7b 100644
--- a/js/src/scrollspy.js
+++ b/js/src/scrollspy.js
@@ -146,10 +146,9 @@ class ScrollSpy extends BaseComponent {
}
dispose() {
- Data.removeData(this._element, DATA_KEY)
+ super.dispose()
EventHandler.off(this._scrollElement, EVENT_KEY)
- this._element = null
this._scrollElement = null
this._config = null
this._selector = null
diff --git a/js/src/tab.js b/js/src/tab.js
index 523810a392..a57d1b12dd 100644
--- a/js/src/tab.js
+++ b/js/src/tab.js
@@ -126,11 +126,6 @@ class Tab extends BaseComponent {
}
}
- dispose() {
- Data.removeData(this._element, DATA_KEY)
- this._element = null
- }
-
// Private
_activate(element, container, callback) {
diff --git a/js/src/toast.js b/js/src/toast.js
index c351139be0..04917869df 100644
--- a/js/src/toast.js
+++ b/js/src/toast.js
@@ -165,9 +165,8 @@ class Toast extends BaseComponent {
}
EventHandler.off(this._element, EVENT_CLICK_DISMISS)
- Data.removeData(this._element, DATA_KEY)
- this._element = null
+ super.dispose()
this._config = null
}
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index 99f910efc7..b844320653 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -229,8 +229,6 @@ class Tooltip extends BaseComponent {
dispose() {
clearTimeout(this._timeout)
- Data.removeData(this._element, this.constructor.DATA_KEY)
-
EventHandler.off(this._element, this.constructor.EVENT_KEY)
EventHandler.off(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler)
@@ -247,9 +245,9 @@ class Tooltip extends BaseComponent {
}
this._popper = null
- this._element = null
this.config = null
this.tip = null
+ super.dispose()
}
show() {