- From: Aryeh Gregor <Simetrical+w3c@gmail.com>
- Date: Fri, 13 May 2011 14:52:51 -0400
On Fri, May 13, 2011 at 2:13 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote: > Note that the table comments above are telling. ?If you want to allow > selection of a table column, you have to allow multirange selection. There's > just no way about it. Yes, I know. But the specific way Gecko handles multi-Range Selections often doesn't make sense. For instance, run this in Live DOM Viewer: <!doctype html> <script> var selection = getSelection(); selection.removeAllRanges(); var range = document.createRange(); range.setStart(document.head, 0); selection.addRange(range); w(selection.focusNode.nodeName); range = document.createRange(); selection.addRange(range); w(selection.focusNode.nodeName); range = document.createRange(); range.setStart(document.head.firstChild, 0); selection.addRange(range); w(selection.focusNode.nodeName); selection.removeRange(range); w(selection.focusNode.nodeName); </script> The log is: log: HEAD log: #document log: SCRIPT log: HEAD Notice how the focusNode is always that of the last Range added, except that when you remove a Range it suddenly becomes the last Range in document order (i.e., the last one in the order Gecko stores them). So adding and then removing a Range without doing anything else changes the focus/anchor. The weird behavior of multi-Range Selections with execCommand() is also a case in point. So if I get around to speccing all this, I'm going to spec something in these cases that makes more sense than what Gecko does, since it's not like there are likely to be big compat requirements in web content. (But I'm not sure I'll wind up speccing it, since I don't know if any other engines actually want to implement multi-Range Selections.)
Received on Friday, 13 May 2011 11:52:51 UTC