REFACTOR: Remove `Discourse` constants from `cleanDOM`

This commit is contained in:
Robin Ward 2020-08-06 15:34:20 -04:00
parent db443d2289
commit f03f58e52c
2 changed files with 9 additions and 8 deletions

View File

@ -15,7 +15,9 @@ export default {
const router = container.lookup("router:main");
router.on("routeWillChange", viewTrackingRequired);
router.on("routeDidChange", cleanDOM);
router.on("routeDidChange", () => {
cleanDOM(container);
});
let appEvents = container.lookup("service:app-events");
let documentTitle = container.lookup("service:document-title");

View File

@ -1,4 +1,5 @@
import { scheduleOnce } from "@ember/runloop";
function _clean() {
if (window.MiniProfiler) {
window.MiniProfiler.pageTransition();
@ -23,18 +24,16 @@ function _clean() {
.not(".no-blur")
.blur();
Discourse.set("contextCount", 0);
Discourse.__container__.lookup("route:application").send("closeModal");
this.lookup("route:application").send("closeModal");
const hideDropDownFunction = $("html").data("hide-dropdown");
if (hideDropDownFunction) {
hideDropDownFunction();
}
// TODO: Avoid container lookup here
const appEvents = Discourse.__container__.lookup("service:app-events");
appEvents.trigger("dom:clean");
this.lookup("service:app-events").trigger("dom:clean");
this.lookup("service:document-title").updateContextCount(0);
}
export function cleanDOM() {
scheduleOnce("afterRender", _clean);
export function cleanDOM(container) {
scheduleOnce("afterRender", container, _clean);
}