/g/ - Technology & Programing



Anonymous
Odd though. Extracting the text content of a selection is not exactly rocket science. Where's the code for that located?
>>1915510 #
Anonymous
>>1915510 #
I think the fault in your logic is that you assume that the last selection points to textnodes + text offsets. tripleselect selects to node boundaries, which means the selection contains the parent node + node offsets. which in turn causes your isInside to fail since it goes up to the parent element.

https://developer.mozilla.org/en-US/docs/Web/API/Selection says

>Selection.anchorOffset Read only
> Returns a number representing the offset of the selection's anchor within the anchorNode. If anchorNode is a text node, this is the number of characters within anchorNode preceding the anchor. If anchorNode is an element, this is the number of child nodes of the anchorNode preceding the anchor.
Which means the anchor and focus node can either be text Nodes or `Elements.
Making el = el.parentElement conditional on el being a text node might fix it.
>>1915517 #>>1915518 #
Anonymous
>>1915356 #
Done. Used as inspiration. Might look ugly, but whatever.
>>1915513 #
Investigated. Only FF >= 52 supports the selectionchange event.
Anonymous
>>1915513 #
Oh, but this does fix triple click in Nightly. Thanks! Pushing that.

Anonymous
i missed the stream! xdddddddd