add flush phase for structural changes

Working on DOM is much faster on detached DOM nodes than on attached DOM nodes.

This PR delays and coalesces structural changes to the DOM via `requestAnimationFrame` and orders them so that as much work as possible is performed on detached document fragments.