Let's simply reinsert the element respecting it's new position in the
DOM tree, instead of crashing.
Fixes regression in WPT tests caused by introducion of cache for
getElementById().
With this change we maintain a data structure that maps ids to
corresponding elements. This allows us to avoid tree traversal in
getElementById() in all cases except ones when lookup happens for
unconnected elements.