# HG changeset patch # User stighal@opera.com # Date 1326367650 -3600 # Branch stighal_patches_01 # Node ID 410b2b1efb91bf8b3dfa4ad4926f6f51a5a34e6c # Parent c49c2da3c841a58a23daa20c35c3653840b16850 According to the Selection spec for extend [1], the checking of offset compared to parentNode's length should be done before setting the new boundary points for the range which would trigger the node type exception for doctype. [1] http://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#dom-selection-extend diff -r c49c2da3c841 -r 410b2b1efb91 selecttest/extend.html --- a/selecttest/extend.html Thu Jan 12 11:32:57 2012 +0100 +++ b/selecttest/extend.html Thu Jan 12 12:27:30 2012 +0100 @@ -108,6 +108,13 @@ return; } + if (offset < 0 || offset > getNodeLength(node)) { + assert_throws("INDEX_SIZE_ERR", function() { + selection.extend(node, offset); + }, "extend() to an offset that's negative or greater than node length (" + getNodeLength(node) + ") must throw INDEX_SIZE_ERR"); + return; + } + if (node.nodeType == Node.DOCUMENT_TYPE_NODE) { assert_throws("INVALID_NODE_TYPE_ERR", function() { selection.extend(node, offset); @@ -115,13 +122,6 @@ return; } - if (offset < 0 || offset > getNodeLength(node)) { - assert_throws("INDEX_SIZE_ERR", function() { - selection.extend(node, offset); - }, "extend() to an offset that's negative or greater than node length (" + getNodeLength(node) + ") must throw INDEX_SIZE_ERR"); - return; - } - var range = selection.getRangeAt(selection.rangeCount - 1); var rangeRoot = furthestAncestor(range.startContainer); var nodeRoot = furthestAncestor(node);