Estoy usando la API de Mutation Observer para escuchar las mutaciones DOM:
// Select the node that will be observed for mutations const targetNode = document.getElementById('some-id'); // Options for the observer (which mutations to observe) const config = { attributes: true, childList: true, subtree: true }; // Callback function to execute when mutations are observed const callback = function(mutationsList, observer) { for(const mutation of mutationsList) { if (mutation.type === 'childList') { console.log('mutation:', mutation); } } }; // Create an observer instance linked to the callback function const observer = new MutationObserver(callback); // Start observing the target node for configured mutations observer.observe(targetNode, config);Al recibir una mutación de childList, me gustaría saber el estado del DOM antes de la mutación. Pero cuando se llama a la devolución de llamada, ya es posterior. ¿Hay una manera de hacer eso?