Some DOM Element interfaces for DOM Ranges

DOM Ranges are really tough to work with. It takes a lot more code
than it should to do simple things, such as getting all of the
elements contained in the range. This is particularly problematic for
makers of designMode/contentEditable rich text editors, which usually
have "Bold"/"Italic"/"Underline" buttons that have to reflect the
state of the current selection. They have to do a lot of convoluted
DOM stuff to find the elements in the range to figure out if they're
bold or not (queryCommandState tends to lie :-P).

I think it would be useful to have some interfaces from DOM Elements
available on DOM Ranges for accessing the contents of the range. For
example, childNodes, getElementsByTagName, and
querySelector/querySelectorAll would work as if they were run against
the common ancestor container of the range, with all results not in
the range removed. This would let developers use interfaces they are
probably quite familiar with when using ranges.

-- 
David Bloom

Received on Friday, 11 April 2008 14:41:29 UTC