Closed Bug 129742 Opened 23 years ago Closed 23 years ago

Hang when going up the offsetParent-path

Categories

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

x86
Linux
defect
Not set
critical

Tracking

()

RESOLVED DUPLICATE of bug 13350

People

(Reporter: moz, Assigned: jst)

References

()

Details

From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 BuildID: 2002020415 Trying to write my first piece of JavaScript I've hung mozilla: I'm trying to calculate the absolute position of an element and therefore I'm adding up all the offsetLeft and offsetTop values belonging to all offsetParents of the element (I've no idea whether this is the right way to do this). This seems to hang mozilla with a high CPU load. I've stripped down the testcase a bit. Reproducible: Always Steps to Reproduce: 1.Go to the testcase. 2.Move the mouse over the given link Actual Results: Mozilla gets irresponsive Expected Results: Stay responsive, give me a chance to debug my code :)
it's in an infinite loop within findPosY shouldn't it be: 64 obje = obje.obj.offsetParent ? you can use the JavaScript debugger to debug this. just set breakpoints before it hangs in your code, and then step (into) through it.
Browser, not engine ---> DOM Level 0
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
I agree with Andrew; this causes an infinite loop in findPosY: while (obje.obj.offsetParent) { curtop += obje.obj.offsetTop; obj = obje.obj.offsetParent; } The test condition |obje.obj.offsetParent| is not being altered in any way inside the loop, so the loop is never going to end... Similarly for findPosX. Marking Invalid; sorry -
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → INVALID
More detail on the above: In looking through your code, note that the incoming parameter |obje| has a property called "obj". That is, |obje.obj| is defined. However, your assignment in the body of the loop says obj = obje.obj.offsetParent; What you are doing by this is defining a NEW variable |obj|, even though the |var| keyword has not been used. Thus we now have TWO indpendent things: |obje.obj| and |obj|. That is why the assignment above does nothing to affect the test condition |obje.obj.offsetParent|. As Andrew suggested, you probably meant to do this instead: obje = obje.obj.offsetParent
Thank's for your help. I duplicate the bug to bug 13350. A hang is after all a bug. Staying responsive would be very nice in many circumstances.
Reopening in order to duplicate.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
*** This bug has been marked as a duplicate of 13350 ***
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.