-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Make unhide function work as expected in html reporter #4051
Conversation
Fixed HTMLCollection iteration to make unhide function work as expected
Could someone test, confirm and review this PR, please? Members, contributors, others ... ? |
@Lindsay-Needs-Sleep thanks 👍 |
This sounds very weird to me with little understanding of HTML/browsers. But I got so far that:
Is |
For clarification, as you noted, In the code below, the code in line 3 will change the ith element's class name to 'suite' and consequently pop the ith element from the variable 'els' since the ith element is not included in
This will inevitably change the indices of the remaining elements still in the list, making index-based loops cause unexpected behaviors when iterating over the HTMLCollection. So, I changed the code to change the class name of each element while the list is not empty rather than iterating over each index.
Hope this helps your understanding. As of
|
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.
@pec9399 thank you for your detailed explanation.
Description
Fixed the iteration of the HTMLCollection object in the unhide function of the html reporter. Since the length of the HTMLCollection changes as the elements' class names get updated (as HTMLCollection works 'live'), it cannot be updated using an index-based for loop.
Description of the Change
Changed the index-based for loop iteration to a while loop, updating the first element while the length of the HTMLCollection is larger than 0.
Why should this be in core?
It a bug (although minor) that makes filtering by passes/failures doesn't work properly as expected.
Benefits
Filtering by passes / filters in html reporter works properly even after unhiding objects.
Possible Drawbacks
None
Applicable issues
Closes #4048