Skip to content

Conversation

@brendankenny
Copy link
Contributor

fixes #8725

The issue was that domstats starts with a 0 as the max number of children seen as the base case, an empty <body> has 0 children (which isn't more than 0), and so parentWithMostChildren stayed as null.

Instead we start with a -1 so that there will always be at least <body> in there. Could have also gone with a >= check, but that changes it so parentWithMostChildren is the last one seen if there are ties, which would sort of be a breaking change. This seemed better (and more the original intent, I guess).

let deepestElement = null;
let maxDepth = 0;
let maxWidth = 0;
let maxDepth = -1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxDepth doesn't need to change (<body> counts as depth 1 which is > 0), but it seemed weird not to change it as well :)

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, should we get a smoketest in there?

@brendankenny
Copy link
Contributor Author

nice, should we get a smoketest in there?

It is unfortunate to not have a regression test, but it felt like overkill to add a smoke test (+5 seconds to all future test runs?) for a trivial corner case of a single audit that can only occur with completely empty pages...

Where do you fall on that trade off?

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know I fall into the ship it camp, it just felt like something @brendankenny would say 😉

LGTM!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dom Size fails when no body present

3 participants