Hard
What code is missing to implement a memory leak detector that monitors DOM mutations?
1class MemoryLeakDetector {2 constructor() {3 this.nodeMap = new WeakMap();4 this.detachedNodes = new Set();5 this.observer = new MutationObserver(this.handleMutations.bind(this));6 }78 start() {9 this.observer.observe(document.body, {10 childList: true,11 subtree: true12 });13 }1415 handleMutations(mutations) {16 mutations.forEach(mutation => {17 _______________________18 _______________________19 _______________________20 });21 }2223 detectLeaks() {24 return Array.from(this.detachedNodes)25 .filter(node => this.isLikelyLeak(node));26 }2728 isLikelyLeak(node) {29 return !document.contains(node) &&30 this.hasEventListeners(node);31 }32}