Fix js bug when firstChild/lastChild don't exist in fixRangeOverflow

For this error:
> Uncaught NotFoundError: An attempt was made to reference a Node in a context where it does not exist.