Remove whitespace in text and try replacing the child with the new node