diff --git a/packages/@ember/-internals/meta/lib/meta.ts b/packages/@ember/-internals/meta/lib/meta.ts index 2ea31b0db30..c4bf55046e7 100644 --- a/packages/@ember/-internals/meta/lib/meta.ts +++ b/packages/@ember/-internals/meta/lib/meta.ts @@ -619,6 +619,10 @@ export class Meta { } else { // update own listener listener.kind = kind; + + // TODO: Remove this when removing REMOVE_ALL, it won't be necessary + listener.target = target; + listener.method = method; } } } diff --git a/packages/@ember/-internals/meta/tests/listeners_test.js b/packages/@ember/-internals/meta/tests/listeners_test.js index bb1bdb0e2b0..8fe1eeeb36e 100644 --- a/packages/@ember/-internals/meta/tests/listeners_test.js +++ b/packages/@ember/-internals/meta/tests/listeners_test.js @@ -155,5 +155,31 @@ moduleFor( 'one reopen call after mutating parents and flattening out of order' ); } + + ['@test REMOVE_ALL does not interfere with future adds'](assert) { + expectDeprecation(() => { + let t = {}; + let m = meta({}); + + m.addToListeners('hello', t, 'm', 0); + let matching = m.matchingListeners('hello'); + + assert.equal(matching.length, 3); + assert.equal(matching[0], t); + + // Remove all listeners + m.removeAllListeners('hello'); + + matching = m.matchingListeners('hello'); + assert.equal(matching, undefined); + + m.addToListeners('hello', t, 'm', 0); + matching = m.matchingListeners('hello'); + + // listener was added back successfully + assert.equal(matching.length, 3); + assert.equal(matching[0], t); + }); + } } );