#188 ✓fixed_in_master_branch
John-David Dalton

YYdscvafZTgajkdfv

Reported by John-David Dalton | July 11th, 2008 @ 05:27 PM | in 1.7

Garrett Smith has pointed out various bugs with offsetTop and 
offsetLeft and we need to create a patch for their use in 
Element#cumulativeOffset and Element#positionedOffset.

Method cumulativeOffsets doesn't account for the many problems:

  • Doesn't account for body.offsetTop ignoring BODY's margin.
  • Doesn't account for BODY being a magic offsetParent.
  • Doesn't add parentNode borderWidth / clientLeft/Top.
  • Doesn't consider Moz bug with border on BODY. [bug report]
A simple example can demonstrate a few of these:

<!DOCTYPE html>
<html>
<head><title>offsetTop border parent</title>
<script src="../library/prototype-1.6.0.2.js"></script>
</head>

<body style="border: 10px solid;margin:10px;">
<div style='border: 1px solid red;position:relative' id='a'>a</div>

</body>
</html>

Now Try:

javascript:alert(Element.Methods.cumulativeOffset(document.getElementById('a')))

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Attachments

Pages