Skip to content

Improve effectiveness of spec JSDOM reset#9737

Merged
aduth merged 1 commit intomainfrom
aduth-jsdom-reset-durable
Dec 11, 2023
Merged

Improve effectiveness of spec JSDOM reset#9737
aduth merged 1 commit intomainfrom
aduth-jsdom-reset-durable

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Dec 11, 2023

🛠 Summary of changes

Updates JavaScript specs to more effectively reset the simulated DOM between test cases:

  • Remove elements appended to <head> as well as those in <body>
  • Reset URL values more universally via the reconfigure helper

This is extracted from #9674 (0ae5baa76e8e4eb08e82d95e1918c0d8fe4ed30b), where it was observed that:

📜 Testing Plan

JavaScript tests should pass:

  • yarn test

changelog: Internal, Automated Testing, Improve effectiveness of spec JSDOM reset
document.body.removeChild(document.body.firstChild);
for (const element of [document.head, document.body]) {
while (element.firstChild) {
element.firstChild.remove();
Copy link
Contributor Author

@aduth aduth Dec 11, 2023

Choose a reason for hiding this comment

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

Element#remove wasn't supported in IE11 which is why you see parent.removeChild(child) in a lot of sample snippets. We shouldn't need to worry about that compatibility in the context of specs, since JSDOM supports Element#remove.

@aduth aduth merged commit f5cc85c into main Dec 11, 2023
@aduth aduth deleted the aduth-jsdom-reset-durable branch December 11, 2023 19:11
@jmhooper jmhooper mentioned this pull request Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants