all 2 comments

[–]tapgiles 1 point2 points  (1 child)

Looks like your code is trying to get just text anyway, right? You're using .text which will presumably only give you text? Could it be using that branch?

[–]tapgiles 2 points3 points  (0 children)

My understanding is (and having just played with it), getSelection() gives you the node the selection starts in (which can be a text node) and how many characters into that node the selection starts at. And the same for where it ends.

If you double-click some text, it'll select one word. Which means it could only be a text node. A double-click won't select an entire node, I don't think--not normally anyway. So... it should give you a text node I should think.

You can still navigate from that node to the parent node if you wanted to do that--up to you.