[go: nahoru, domu]

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

core(domstats): support an empty html body #9340

Merged
merged 1 commit into from
Jul 10, 2019
Merged

core(domstats): support an empty html body #9340

merged 1 commit into from
Jul 10, 2019

Conversation

brendankenny
Copy link
Member

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).

@@ -86,8 +86,8 @@ function elementPathInDOM(element) {
/* istanbul ignore next */
function getDOMStats(element, deep = true) {
let deepestElement = null;
let maxDepth = 0;
let maxWidth = 0;
let maxDepth = -1;
Copy link
Member 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
Member 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