Properly select and erase text nodes