Bugzilla – Bug 15533
Index check in selection.extend() should be done before node type test.
Last modified: 2012-01-13 17:05:35 UTC
Created attachment 1066 [details]
Test patch, index
According to the Selection spec for extend , 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.
In the selecttest/extend.html tests there are a few tests that expect the browser to throw an INVALID_NODE_TYPE_ERR, where in fact the INDEX_SIZE_ERR exception should be checked and thrown first.
Actually, it seems like I should just reference DOM4's "set the start or end" algorithm for simplicity. This results in throwing InvalidNodeTypeError first. This:
throws InvalidNodeTypeError in Firefox 12.0a1 and Chrome 17 dev, per DOM4; and IndexSizeError in IE9 and Opera Next 12.00 alpha, not per DOM4. We should be consistent and throw InvalidNodeTypeError for extend() just like setStart().
I've changed the spec to reference DOM4's algorithm, which I believe makes the tests correct:
Please tell me if this isn't satisfactory. Thanks!
(In reply to comment #1)
> Please tell me if this isn't satisfactory. Thanks!
The changes look very good. Thank you for quick response.
Just FYI, I'm currently rewriting the Range and Selection code in Opera, and upcoming versions will match the spec, more or less, to the letter.
Great! Opera's Range/Selection implementation was always a not-so-good match for the other browsers I tested, and I hope my spec/tests are helpful in improving that. Please give me any further feedback you have and I'll try to respond ASAP.