svg: detach in reverse order of attach