DEV: encapsulates _events and clearing it at app-events module level (#9489)

This commit is contained in:
Joffrey JAFFEUX
2020-04-21 17:27:17 +02:00
committed by GitHub
parent c9cdd12e97
commit 1eb9bc4cec
2 changed files with 30 additions and 21 deletions

View File

@ -189,16 +189,9 @@ QUnit.testDone(function() {
// ensures any event not removed is not leaking between tests
// most likely in intialisers, other places (controller, component...)
// should be fixed in code
var appEvents = window.Discourse.__container__.lookup("service:app-events");
var events = appEvents.__proto__._events;
Object.keys(events).forEach(function(eventKey) {
var event = events[eventKey];
event.forEach(function(listener) {
if (appEvents.has(eventKey)) {
appEvents.off(eventKey, listener.target, listener.fn);
}
});
});
require("discourse/services/app-events").clearAppEventsCache(
window.Discourse.__container__
);
window.MessageBus.unsubscribe("*");
delete window.server;