Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove element event listeners through base component #33429

Merged
merged 3 commits into from Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions js/src/base-component.js
Expand Up @@ -6,6 +6,7 @@
*/

import Data from './dom/data'
import EventHandler from './dom/event-handler'

/**
* ------------------------------------------------------------------------
Expand All @@ -29,6 +30,7 @@ class BaseComponent {

dispose() {
Data.remove(this._element, this.constructor.DATA_KEY)
EventHandler.off(this._element, `.${this.constructor.DATA_KEY}`)
this._element = null
}

Expand Down
2 changes: 0 additions & 2 deletions js/src/carousel.js
Expand Up @@ -216,8 +216,6 @@ class Carousel extends BaseComponent {
}

dispose() {
EventHandler.off(this._element, EVENT_KEY)

this._items = null
this._config = null
this._interval = null
Expand Down
1 change: 0 additions & 1 deletion js/src/dropdown.js
Expand Up @@ -237,7 +237,6 @@ class Dropdown extends BaseComponent {
}

dispose() {
EventHandler.off(this._element, EVENT_KEY)
this._menu = null

if (this._popper) {
Expand Down
2 changes: 1 addition & 1 deletion js/src/modal.js
Expand Up @@ -190,7 +190,7 @@ class Modal extends BaseComponent {
}

dispose() {
[window, this._element, this._dialog]
[window, this._dialog]
.forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY))

super.dispose()
Expand Down
2 changes: 0 additions & 2 deletions js/src/toast.js
Expand Up @@ -156,8 +156,6 @@ class Toast extends BaseComponent {
this._element.classList.remove(CLASS_NAME_SHOW)
}

EventHandler.off(this._element, EVENT_CLICK_DISMISS)

super.dispose()
this._config = null
}
Expand Down
1 change: 0 additions & 1 deletion js/src/tooltip.js
Expand Up @@ -215,7 +215,6 @@ class Tooltip extends BaseComponent {
dispose() {
clearTimeout(this._timeout)

EventHandler.off(this._element, this.constructor.EVENT_KEY)
EventHandler.off(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler)

if (this.tip && this.tip.parentNode) {
Expand Down