I'm getting a text node (node.nodeType == 3) returned from the getSelection range, eg.:
var selectionRange = selection.getRangeAt(0);
var startContainer = selectionRange.startContainer;
This startContainer usually is a text node, eg the following html:
<p>Paragraph in <u>parag</u>raph.</p>
Would result in the text node with text "raph." if | denotes the selection:
<p>Paragraph in <u>parag</u>r|aph|.</p>
That's right, the selected text is aph and the text node is raph., because before raph there is a new text node inside the u node.
Now, when calling $(startContainer).prevAll().each(function(index, node) ...
I expected this to return U (which contains a text node with parag) and another text node (which contains Paragraph in ).
However, it returns only U and not the text node to the left of it.
Why is this? How do I get all same-level nodes before my startContainer, including text nodes with jQuery?