Csswg-drafts: [cssom-view] offsetTop/Left spec seems to be pretty confused when scrolling is involved

Created on 25 Sep 2017  路  1Comment  路  Source: w3c/csswg-drafts

Simple testcase:

<div id="parent" style="overflow:scroll; height: 100px; position: relative">
  <div id="spacer" style="height: 200px"></div>
  <div id="child" style="border: 1px solid green"></div>
</div>

Load this, scroll the scrollable div all the way down, examine "child.offsetTop". It comes back as "200" in browsers. The spec at https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsettop, on the other hand says:

Return the result of subtracting the y-coordinate of the top padding edge of the first CSS layout box associated with the offsetParent of the element from the y-coordinate of the top border edge of the first CSS layout box associated with the element, relative to the initial containing block origin, ignoring any transforms that apply to the element and its ancestors.

and in this case this is definitely not 200. The spec is wrong and needs to be fixed, afaict.

Help Wanted cssom-view-1

Most helpful comment

Oh, and I plan to add web platform tests that test the actually correct behavior. Yes, they won't match the spec as written... But we need test coverage here.

>All comments

Oh, and I plan to add web platform tests that test the actually correct behavior. Yes, they won't match the spec as written... But we need test coverage here.

Was this page helpful?
0 / 5 - 0 ratings