Closed Bug 306001 Opened 19 years ago Closed 19 years ago

setStart() and setEnd() throw exception

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 205635

People

(Reporter: surkov, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a1) Gecko/20050821 Firefox/1.6a1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a1) Gecko/20050821 Firefox/1.6a1

If just setted start position is greater than current end then
nsIRange::setStart() throws an exception. Method nsIRange::setEnd() has 
the same behaviour. Specs says: "The start position of a Range is guaranteed to
never be after the end position. To enforce this restriction, if the start is
set to be at a position after the end, the Range is collapsed to that position.
Similarly, if the end is set to be at a position before the start, the Range is
collapsed to that position."

http://lxr.mozilla.org/mozilla/source/content/base/src/nsRange.cpp

nsIRange::setStart()
965     // the start must be before the end
966     if (!IsIncreasing(aParent, aOffset, mEndParent, mEndOffset)) {
967       return NS_ERROR_ILLEGAL_VALUE;
968     }

nsIRange::setEnd()
1018   // start must be before end
1019   if (mIsPositioned &&
!IsIncreasing(mStartParent,mStartOffset,theParent,aOffset))
1020     return NS_ERROR_ILLEGAL_VALUE;.

Reproducible: Always

*** This bug has been marked as a duplicate of 205635 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → VERIFIED
Component: DOM: Traversal-Range → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.