Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Use outerHTML for html() on DOM nodes #1042

Merged
merged 4 commits into from
Sep 30, 2019
Merged

Use outerHTML for html() on DOM nodes #1042

merged 4 commits into from
Sep 30, 2019

Conversation

lemonmade
Copy link
Member

Description

Fixes #802. This PR fixes an issue where we would omit the outermost DOM elements when calling html() on a tree.

Type of change

  • react-testing Patch: Bug/ Documentation fix (non-breaking change which fixes an issue or adds documentation)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have added a changelog entry, prefixed by the type of change noted above

cc/ @TheVedhaGuy, this fixes one of the issues you raised. The other one (Attempted to operate on a mounted tree, but the component is no longer mounted) I think is actually a problem with your component. That error usually happens when some part of the component throws an error, which forces react-testing to unmount the tree. We have a test that verifies the behaviour of components nested in fragments, so I am pretty confident that part works correctly.

@CautionTapeBot
Copy link

We noticed that this PR either modifies or introduces usage of the dangerouslySetInnerHTML attribute, which can cause cross-site scripting (XSS) vulnerabilities. Our team will take a look soon, but for now we recommend reviewing your code to ensure that this is what you intended to use and that there is not a safe alternative available. Docs are available here.

Copy link
Contributor

@marutypes marutypes left a comment

Choose a reason for hiding this comment

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

🎖

Copy link
Contributor

@michenly michenly left a comment

Choose a reason for hiding this comment

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

🎩 and looks greats

@michenly michenly closed this Sep 30, 2019
@michenly michenly deleted the fix-html-dom-node branch September 30, 2019 17:23
@lemonmade lemonmade restored the fix-html-dom-node branch September 30, 2019 17:30
@lemonmade lemonmade reopened this Sep 30, 2019
@lemonmade lemonmade merged commit 9ffb958 into master Sep 30, 2019
@lemonmade lemonmade deleted the fix-html-dom-node branch September 30, 2019 19:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Component that have a React Fragment do not mount properly
4 participants