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

Dom Size fails when no body present #8725

Closed
exterkamp opened this issue Apr 30, 2019 · 5 comments · Fixed by #9340
Closed

Dom Size fails when no body present #8725

exterkamp opened this issue Apr 30, 2019 · 5 comments · Fixed by #9340

Comments

@exterkamp
Copy link
Member

This issue #6806 brought up counting elements in the HEAD, and this PR was made #7241. But it fails to count dom elements in a website like this:

<html>Content</html>

Where there are no <body> tags present, but there are nodes to count.

@patrickhulce
Copy link
Collaborator

patrickhulce commented Apr 30, 2019

Nice catch!!

FWIW, this also fails when body is present. It just fails when there are no elements at all to count :)

i.e. <html>Content<span>hi</span><span>hi2</span><span>hi3</span></html> computes 3 elements as expected

@connorjclark
Copy link
Collaborator

connorjclark commented Jun 28, 2019

I was trying to upload a repro for this to surge but Chrome keeps being smart.

https://misc-hoten.surge.sh/the-incorporeal-doc/

<html>who needs a body with html like mine?</html>

image

<html>Content<span>hi</span><span>hi2</span><span>hi3</span></html>

image

@connorjclark
Copy link
Collaborator

Chrome keeps being smart.

Rather, the html parser spec is very particular about what to do here: http://w3c.github.io/html/syntax.html#the-before-head-insertion-mode

initial -> before html -> before head -> in head -> after head -> in body -> voila.

@connorjclark
Copy link
Collaborator

Anyways, my point is, how are you guys even getting this error to happen? I can't audit a document without a body, because apparently the spec never allows Chrome to make such a document.

@brendankenny
Copy link
Member

Anyways, my point is, how are you guys even getting this error to happen? I can't audit a document without a body, because apparently the spec never allows Chrome to make such a document.

yes, one is automatically created. @patrickhulce pinpointed the actual issue (an empty body)

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

Successfully merging a pull request may close this issue.

4 participants