Skip to content

Commit

Permalink
fixup! Remove event remote listeners references
Browse files Browse the repository at this point in the history
  • Loading branch information
thoughtsunificator committed Nov 27, 2024
1 parent 817ccb5 commit ba3a673
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ class Binding {
* Remove the model and all its children from the DOM and clean up any listener associated with them.
*/
remove() {
for(const { target, type, listener, options } of this._remoteEventListeners) {
target.removeEventListener(type, listener, options)
}
this._remoteEventListeners = []
const listeners = this._listeners.slice()
for(const listener of listeners) {
listener.remove()
Expand All @@ -142,10 +146,6 @@ class Binding {
for(const child of children) {
child.remove()
}
for(const { target, type, listener } of this._remoteEventListeners) {
target.removeEventListener(type, listener)
}
this._remoteEventListeners = []
if(this._parent !== null) {
this._parent._children = this._parent._children.filter(child => child !== this)
}
Expand All @@ -168,7 +168,7 @@ class Binding {
* @param {object} options
*/
addEventListener(target, type, listener, options) {
this._remoteEventListeners.push({ target, type, listener })
this._remoteEventListeners.push({ target, type, listener, options })
target.addEventListener(type, listener, options)
}

Expand Down

0 comments on commit ba3a673

Please sign in to comment.