Re: [cssom-view] Why is body's offsetParent null ?

Anne van Kesteren wrote:

> Actually, you would probably always use getBoundingClientRect() as 
> that's far more consistent and reliable than any of the offset* 
> attributes. They are mainly defined because lots of legacy scripts use 
> them currently to calculate the position of an element using while loops 
> (which the specification handles fine).

So the behavioural difference between body and other elements is
introduced because of MSIE but the Web is full of the following

var t = 0;
var p = myElement;
while (p) {
   t += p.offsetTop;
   p =  p.offsetParent;
// use t

Because of the change you introduce saying document.body.offsetTop
is now always zero, such scripts will give an erroneous result for
non-IE browsers. Right ?


Received on Wednesday, 23 April 2008 09:11:10 UTC