Use range to calculate position of text node
Minor refactoring of range