Weird #JavaScript behavior with Element.remove():
const children = ... // sorted children of container
children.forEach((ch) => ch.remove());
if (1 > 2) {
setTimeout(() => {
for (const child of children) {
container.append(child);
}
}, 0);
} else {
for (const child of children) {
container.append(child);
}
}
The setTimeout branch works, the other not. Anyone? Axel Rauschmayer (npub10fa…rdvy) would you have an idea?
A shallow explanation: removal needs one round of the event loop. But why?