mirror of
https://github.com/twbs/bootstrap.git
synced 2022-11-09 12:25:43 -05:00
add dispose in base component
This commit is contained in:
parent
51a208f119
commit
9eb9d02084
11 changed files with 13 additions and 32 deletions
|
@ -69,11 +69,6 @@ class Alert extends BaseComponent {
|
|||
this._removeElement(rootElement)
|
||||
}
|
||||
|
||||
dispose() {
|
||||
Data.removeData(this._element, DATA_KEY)
|
||||
this._element = null
|
||||
}
|
||||
|
||||
// Private
|
||||
|
||||
_getRootElement(element) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -126,11 +126,6 @@ class Tab extends BaseComponent {
|
|||
}
|
||||
}
|
||||
|
||||
dispose() {
|
||||
Data.removeData(this._element, DATA_KEY)
|
||||
this._element = null
|
||||
}
|
||||
|
||||
// Private
|
||||
|
||||
_activate(element, container, callback) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue