Rangy is only reporting what the browser tells it about the selection and has no opinion about whether the href
attribute is present. As you correctly diagnosed, the problem is that when you click on an <a>
element, the existing selection is destroyed by the time the click event fires. Assuming you continue using these <a>
elements, your options are:
- Use the
mousedown
event instead - Make the
<a>
element unselectable, which will obviously have its own consequences