DEV: reduces jquery usage and memory leaks in composer (PR #14924)

Removes more than 60 jquery function leaks in one Acceptance: Composer run.

GitHub

I guess these could probably be refactor even further some day, but this is probably a good first step.

Minor: are there any cases where this.element is falsy in willDestroyElement()?

Yeh… I tend to be over paranoid this we have ?.. I guess it’s not needed indeed

I think this is an incorrect use of the optional chaining operator:

let dis = { currentUser: { link_posting_access: "none" } };
console.log(dis.currentUser && dis.currentUser.link_posting_access !== "none");
console.log(dis.currentUser?.link_posting_access !== "none");
// false and false, all good

dis = { currentUser: null };
console.log(dis.currentUser && dis.currentUser.link_posting_access !== "none");
console.log(dis.currentUser?.link_posting_access !== "none");
// null and true, oops

Should this event listener be removed at some point? (e.g. willDestroyElement)

Yes indeed, that should do it: DEV: reduces jquery usage and memory leaks in composer by jjaffeux · Pull Request #14924 · discourse/discourse · GitHub