I've been working with selection/range objects, and because to the incredible amount of inconsistencies between browsers for specific selection/range stuff (even more than the DOM) I was wondering if there was a framework that would help me get through them.
-
Have you seen code.google.com/p/ierange ?Roatin Marth– Roatin Marth2010-01-25 19:11:31 +00:00Commented Jan 25, 2010 at 19:11
-
Roatin, this is exactly what i was looking for! Can you make it a question so I can upvote you? :)Luca Matteis– Luca Matteis2010-01-25 19:52:25 +00:00Commented Jan 25, 2010 at 19:52
3 Answers
I've written a new range/selection library called Rangy that is similar in concept to IERange but goes quite a lot further. The core is pretty much complete and currently available to download. I'm currently bugfixing and documenting it and it should be only be a few weeks before a full release.
UPDATE 31 August 2011
Rangy is now stable and at version 1.2 (downloads page).
1 Comment
(Made an answer by request ;)
Take a look at IERange:
IERange is a feature-complete implementation of W3C DOM Ranges for Internet Explorer, allowing users to write one cross-browser version of their range manipulation code.
Supports Range APIs:
document.createRange()startContainer,startOffset,endContainer,endOffset,commonAncestorContainer,collapsedsetStart(),setEnd(),setStartBefore(),setStartAfter(),setEndBefore(),setEndAfter(),selectNode(),selectNodeContents(),collapse()insertNode(),surroundContents()extractContents(),cloneContents(),deleteContents()compareBoundaryPoints(),cloneRange(),createContextualFragment(),toString()
Supports Selection APIs:
- Range support (Webkit-style)
window.getSelection()addRange(),removeAllRanges(),getRangeAt(),toString()
2 Comments
TextRange in terms of nodes and offsets (as a Range does) and converting such and object back into a TextRange. However, it cannot fully abstract away the differences between the two: for example, the underlying TextRange will change in response to changes in the DOM while the IERange built upon it will not reflect these changes. There are also discrepancies between how the user selection is represented as a Range, which are down to the browser. [continued]IERange is hugely slower than getting a DOM Range in other browsers. None of these are the library's fault; it's simply the nature of the problem. In short, best use with care and knowledge of the abstraction IERange represents.