W3C home > Mailing lists > Public > www-style@w3.org > April 2008

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

From: Mike Wilson <mikewse@hotmail.com>
Date: Thu, 24 Apr 2008 00:09:59 +0200
Message-ID: <BAY116-DAV12A775E0B213BCC3971F77A4E30@phx.gbl>
To: "'Sylvain Galineau'" <sylvaing@microsoft.com>
Cc: "'Www-style'" <www-style@w3.org>
Message-ID: <01bf01c8a58e$c59c19e0$0a01a8c0@mikedeskxp>

Hi Sylvain,

I realize your original question was sort of lost so I'll give
my 2 cents on that first:

> The current spec and user agents I have tested - IE7, FF3b5, 
> Safari 3.1, Opera 9.5b1 -  set body's offsetParent property 
> to null even though a) body has offset properties for which 
> b) there is a reference element - html - with box properties 
> of its own.
> My question is : what are the reasons for this beyond 
> compatibility with IE legacy ?

If we agree that
  a) the other browsers algorithms are aimed at cloning IE and
     not inventing something new
  b) majority of existing deployed content is made for IE 
then both these factors are part of the IE legacy. Therefore 
I would say that body.offsetParent==null is all about IE legacy.

> Afaik, it is practically always null today; but in IE8b1's 
> standards mode, it refers to html. From an API design and 
> object model standpoint, the latter is what the caller 
> expects, imo.

Yeah, this is what I also believe would be the natural thing if 
designing the API from scratch.

> As mentioned by others earlier, simple list-walking patterns 
> such as the one below from Prototype's dom.js are fairly common :
> cumulativeOffset: function(element) {
>     var valueT = 0, valueL = 0;
>     do {
>       valueT += element.offsetTop || 0;
>       valueL += element.offsetLeft || 0;
>       element = element.offsetParent;
>     } while (element);
>     return Element._returnOffset(valueL, valueT);
>   },

[nit-picking note:]
Aren't they forgetting to add the border from the "middle" 
visited elements?

> ..and our first IE8 Beta may have pulled this rug by a number 
> of pixels for a number of web sites. Some of us at Microsoft 
> judge this to be a welcome fix to a long-standing bug, while 
> others - and I am among the latter - see it as a regression 
> from a de-facto standard behavior.

Are you only looking at the algorithm in the new super-standards
mode, or would this also be changed for the "IE7" standards mode
in IE8?

> To the extent possible, I am looking for informed opinion as 
> well as any data - web sites, frameworks, assumptions 
> explicitly or implicitly stated in related standards - that 
> can give us a better measure of the decision.

The "skipped over" body element in the offsetParent chain of 
IE7- gives me the impression that someone at some point
considered the body element "redundant" and wanted the first-
level children to stand out as "top-level" elements. (Although
it would have been more logical to have their offsetParent==null 
instead of ==HTML, then.)

Best regards
Mike Wilson
Received on Wednesday, 23 April 2008 22:10:55 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:36 UTC