Skip to content

Commit

Permalink
completely remove function listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
pzuraq committed Sep 27, 2018
1 parent 7e1c4be commit 6b685a0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/@ember/-internals/meta/lib/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,20 @@ export class Meta {
kind,
} as Listener);
} else {
// update own listener
listeners[i].kind = kind;
let listener = listeners[i];
// If the listener is our own function listener and we are trying to
// remove it, we want to splice it out entirely so we don't hold onto a
// reference.
if (
typeof method === 'function' &&
kind === ListenerKind.REMOVE &&
listener.kind !== ListenerKind.REMOVE
) {
listeners.splice(i, 1);
} else {
// update own listener
listener.kind = kind;
}
}
}

Expand Down

0 comments on commit 6b685a0

Please sign in to comment.