Reputation: 995
It looks like the newest Alpha version of rangy has deprecated the createNodeIterator() method and replaced it with a more general createIterator() instead. It seems the syntax for using it is a bit different as well.
Say a user has gone through and made multiple selections to a document and applied CSS classes to those selections. My goal is make sure a user is unable to make overlapping selections to text that already has a rangy-applied CSS class.
Could I still do this with the createIterator function? Is there a built-in function that could help me with this otherwise?
Upvotes: 0
Views: 692
Reputation: 995
I went with this solution:
var isHighlighted = false,
range = rangy.getSelection().getRangeAt(0);
var it = range.getNodes([3], function(node) {
return node.parentNode.tagName == 'SPAN' && node.parentNode.className == 'highlight';
});
if (it.length > 0)
isHighlighted = true;
return isHighlighted;
Upvotes: 2