Fix #13233: re-allow .replaceWith of text nodes. Close gh-1137.
(cherry picked from commit 6b1b0a26b4d485b4d9f334286efed5dfe33e3f3f)