solved more cases by allowing REPLACE_ELEMENT to be used on exchanging a text node with a different type of node