Make sure template nodes are created/moved within the correct document context.