Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
refactor: Improve code coverage #517
refactor: Improve code coverage #517
Changes from all commits
c46c447
1a53834
ebbb8aa
ab5d084
bfa6df1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeScript validates this, we don't need this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty states won't be used in the parser, but we can test them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Why does
hasNumberedHeaderInScope
exist if parse5 doesn’t use it? Should we deprecate it and remove it in a major then?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these functions are used, can we instead add unit tests (input/output) of parsing behavior that depends on the result of these functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasNumberedHeaderInScope
is used by the parser. The only thing that the parser cannot reach is the default return value, eg. for an empty stack.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean this early return
parse5/packages/parse5/lib/parser/open-element-stack.ts
Line 270 in 8e22fe4
parse5/packages/parse5/lib/parser/open-element-stack.ts
Line 278 in 8e22fe4
Could you change that early return to a break in that case, to fix the coverage?
Not sure about the algorithm: but it seems off that the default for that function i
true
? I’d expect, with such a function name, to exit early withtrue
, and otherwise returnfalse
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The relevant part of the spec is https://html.spec.whatwg.org/multipage/parsing.html#has-an-element-in-scope
The algorithm explicitly doesn't consider the possibility of an empty stack:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I recommend using a
c8 ignore
(or similar), with this as an explanation: