Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cssom-view] No browsers honor "the HTML body element" in offsetTop #584

Open
frewsxcv opened this issue Oct 10, 2016 · 7 comments
Open

Comments

@frewsxcv
Copy link
Member

https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsettop

If the element is the HTML body element or does not have any associated CSS layout box return zero and terminate this algorithm.

<html>
<body id=body></body>
<script>
var body = document.getElementById('body');
var innerBody = document.createElement('body');
body.appendChild(innerBody);
window.alert(innerBody.offsetTop);
window.alert(innerBody.offsetLeft);
</script>
</html>

At the time of writing, Safari, Chrome, and Firefox all output 0 and 0 for this.

@upsuper
Copy link
Member

upsuper commented Oct 11, 2016

So the issue is that "the HTML body element" refers to

the first body HTML element child of the root HTML element html

and thus any other <body> should just be treated as normal elements.

I think this is something browsers should fix. Changing the spec on this doesn't make much sense.

Probably consider filing bugs to browsers and submitting a web-platform test (or probably css wg test) for this.

@frewsxcv
Copy link
Member Author

@zcorpan
Copy link
Member

zcorpan commented Oct 19, 2016

Thanks. I don't have a strong opinion on this. But if we already have interop on "any body element", then shouldn't we just spec that?

@upsuper
Copy link
Member

upsuper commented Oct 19, 2016

But that behavior doesn't really make sense...

@zcorpan
Copy link
Member

zcorpan commented Oct 19, 2016

It's non-conforming to have a body element anywhere other than as "the body element", so it's OK to not make sense. There's also precedent for similar nonsense, like:

<script>
 var body = document.createElement('body');
 body.onload = function() { alert(1) }; // same as window.onload
</script>

@frewsxcv
Copy link
Member Author

The Chrome team just closed the ticket in their tracker as WONTFIX:

Not likely we'll change this. Closing for now.

The Firefox ticket is still open.

At what point should the spec just be updated to reflect the state of the world now?

@zcorpan
Copy link
Member

zcorpan commented Oct 29, 2020

@frewsxcv I think the spec should be updated. cc @smfr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants