12

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.

2
  • Have you seen code.google.com/p/ierange ? Commented 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? :) Commented Jan 25, 2010 at 19:52

3 Answers 3

13

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your great work on Rangy Tim Down. I'm using your lib in my new project and already have send you a bug report. I think it would be a good idea to create a mailing list, so that it is possible to discuss issues/features and suggest new features (maybe with a patch). Eg., I'm currently trying to get a startOffset and endOffset for the commonAncestorContainer rather than start/end containers. This would be a helpful feature I believe.
8

(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, collapsed
  • setStart(), 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

IERange's biggest strength is its algorithms for expressing a 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]
Also note that creating an 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.
1

fieldselection is a very usable jquery plugin for selection/range manipulation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.