Is this right? Looks funny. I would expect `var wholeDocument = false;`, not sure that the `selectionRange;` bit is doing here.