Mutation bug #2
HTML
<!DOCTYPE html>
<div id="a">
<div id="b"></div>
</div>
<div id="c">text</div>
<script>
function process_records(records){
for (const r of records){
console.log(`added: ${r.addedNodes.length}; removed: ${r.removedNodes.length}`);
}
}
const observer = new MutationObserver(process_records);
const a = document.getElementById("a");
const b = document.getElementById("b");
const c = document.getElementById("c");
const txt = c.firstChild;
observer.observe(a, {
subtree: true,
childList: true,
attributes: true,
attributeOldValue: true,
characterData: true,
characterDataOldValue: true,
});
c.after(b);
process_records(observer.takeRecords());
observer.disconnect();
</script>