Skip to content

Commit ca313f2

Browse files
MarkFalconbridgeKent C. Dodds
authored and
Kent C. Dodds
committed
fix: reorder cleanupAtContainer code (#327)
Closes #326
1 parent 75a98b5 commit ca313f2

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

.all-contributorsrc

+10
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,16 @@
698698
"contributions": [
699699
"doc"
700700
]
701+
},
702+
{
703+
"login": "MarkFalconbridge",
704+
"name": "MarkFalconbridge",
705+
"avatar_url": "https://avatars1.githubusercontent.com/u/20678943?v=4",
706+
"profile": "https://github.com/MarkFalconbridge",
707+
"contributions": [
708+
"bug",
709+
"code"
710+
]
701711
}
702712
],
703713
"contributorsPerLine": 7

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ practices.</p>
2626
[![version][version-badge]][package] [![downloads][downloads-badge]][npmtrends]
2727
[![MIT License][license-badge]][license]
2828

29-
[![All Contributors](https://img.shields.io/badge/all_contributors-71-orange.svg?style=flat-square)](#contributors)
29+
[![All Contributors](https://img.shields.io/badge/all_contributors-72-orange.svg?style=flat-square)](#contributors)
3030
[![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc]
3131
[![Join the community on Spectrum][spectrum-badge]][spectrum]
3232

@@ -221,7 +221,7 @@ Thanks goes to these people ([emoji key][emojis]):
221221
| [<img src="https://avatars2.githubusercontent.com/u/20361668?v=4" width="100px;" alt="Michiel Nuyts"/><br /><sub><b>Michiel Nuyts</b></sub>](https://github.com/Michielnuyts)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=Michielnuyts "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1195863?v=4" width="100px;" alt="Joe Ng'ethe"/><br /><sub><b>Joe Ng'ethe</b></sub>](https://github.com/joeynimu)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=joeynimu "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=joeynimu "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/19998290?v=4" width="100px;" alt="Kate"/><br /><sub><b>Kate</b></sub>](https://github.com/Enikol)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=Enikol "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/11980217?v=4" width="100px;" alt="Sean"/><br /><sub><b>Sean</b></sub>](http://www.seanrparker.com)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=SeanRParker "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/17031?v=4" width="100px;" alt="James Long"/><br /><sub><b>James Long</b></sub>](http://jlongster.com)<br />[🤔](#ideas-jlongster "Ideas, Planning, & Feedback") [📦](#platform-jlongster "Packaging/porting to new platform") | [<img src="https://avatars1.githubusercontent.com/u/10118777?v=4" width="100px;" alt="Herb Hagely"/><br /><sub><b>Herb Hagely</b></sub>](https://github.com/hhagely)<br />[💡](#example-hhagely "Examples") | [<img src="https://avatars2.githubusercontent.com/u/5779538?v=4" width="100px;" alt="Alex Wendte"/><br /><sub><b>Alex Wendte</b></sub>](http://www.wendtedesigns.com/)<br />[💡](#example-themostcolm "Examples") |
222222
| [<img src="https://avatars0.githubusercontent.com/u/6998954?v=4" width="100px;" alt="Monica Powell"/><br /><sub><b>Monica Powell</b></sub>](http://www.aboutmonica.com)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=M0nica "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/2699953?v=4" width="100px;" alt="Vitaly Sivkov"/><br /><sub><b>Vitaly Sivkov</b></sub>](http://sivkoff.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=sivkoff "Code") | [<img src="https://avatars3.githubusercontent.com/u/7049?v=4" width="100px;" alt="Weyert de Boer"/><br /><sub><b>Weyert de Boer</b></sub>](https://github.com/weyert)<br />[🤔](#ideas-weyert "Ideas, Planning, & Feedback") [👀](#review-weyert "Reviewed Pull Requests") | [<img src="https://avatars3.githubusercontent.com/u/13613037?v=4" width="100px;" alt="EstebanMarin"/><br /><sub><b>EstebanMarin</b></sub>](https://github.com/EstebanMarin)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=EstebanMarin "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/13953703?v=4" width="100px;" alt="Victor Martins"/><br /><sub><b>Victor Martins</b></sub>](https://github.com/vctormb)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=vctormb "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/19773?v=4" width="100px;" alt="Royston Shufflebotham"/><br /><sub><b>Royston Shufflebotham</b></sub>](https://github.com/RoystonS)<br />[🐛](https://github.com/kentcdodds/react-testing-library/issues?q=author%3ARoystonS "Bug reports") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=RoystonS "Documentation") [💡](#example-RoystonS "Examples") | [<img src="https://avatars0.githubusercontent.com/u/6834804?v=4" width="100px;" alt="chrbala"/><br /><sub><b>chrbala</b></sub>](https://github.com/chrbala)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=chrbala "Code") |
223223
| [<img src="https://avatars3.githubusercontent.com/u/887639?v=4" width="100px;" alt="Donavon West"/><br /><sub><b>Donavon West</b></sub>](http://donavon.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=donavon "Code") [📖](https://github.com/kentcdodds/react-testing-library/commits?author=donavon "Documentation") [🤔](#ideas-donavon "Ideas, Planning, & Feedback") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=donavon "Tests") | [<img src="https://avatars2.githubusercontent.com/u/689081?v=4" width="100px;" alt="Richard Maisano"/><br /><sub><b>Richard Maisano</b></sub>](https://github.com/maisano)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=maisano "Code") | [<img src="https://avatars0.githubusercontent.com/u/5244986?v=4" width="100px;" alt="Marco Biedermann"/><br /><sub><b>Marco Biedermann</b></sub>](https://www.marcobiedermann.com)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=marcobiedermann "Code") [🚧](#maintenance-marcobiedermann "Maintenance") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=marcobiedermann "Tests") | [<img src="https://avatars3.githubusercontent.com/u/93752?v=4" width="100px;" alt="Alex Zherdev"/><br /><sub><b>Alex Zherdev</b></sub>](https://github.com/alexzherdev)<br />[🐛](https://github.com/kentcdodds/react-testing-library/issues?q=author%3Aalexzherdev "Bug reports") [💻](https://github.com/kentcdodds/react-testing-library/commits?author=alexzherdev "Code") | [<img src="https://avatars0.githubusercontent.com/u/5133846?v=4" width="100px;" alt="André Matulionis dos Santos"/><br /><sub><b>André Matulionis dos Santos</b></sub>](https://twitter.com/Andrewmat)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=Andrewmat "Code") [💡](#example-Andrewmat "Examples") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=Andrewmat "Tests") | [<img src="https://avatars0.githubusercontent.com/u/1096340?v=4" width="100px;" alt="Daniel K."/><br /><sub><b>Daniel K.</b></sub>](https://github.com/FredyC)<br />[🐛](https://github.com/kentcdodds/react-testing-library/issues?q=author%3AFredyC "Bug reports") [💻](https://github.com/kentcdodds/react-testing-library/commits?author=FredyC "Code") [🤔](#ideas-FredyC "Ideas, Planning, & Feedback") [⚠️](https://github.com/kentcdodds/react-testing-library/commits?author=FredyC "Tests") | [<img src="https://avatars0.githubusercontent.com/u/40938625?v=4" width="100px;" alt="mohamedmagdy17593"/><br /><sub><b>mohamedmagdy17593</b></sub>](https://github.com/mohamedmagdy17593)<br />[💻](https://github.com/kentcdodds/react-testing-library/commits?author=mohamedmagdy17593 "Code") |
224-
| [<img src="https://avatars2.githubusercontent.com/u/251288?v=4" width="100px;" alt="Loren ☺️"/><br /><sub><b>Loren ☺️</b></sub>](http://lorensr.me)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=lorensr "Documentation") |
224+
| [<img src="https://avatars2.githubusercontent.com/u/251288?v=4" width="100px;" alt="Loren ☺️"/><br /><sub><b>Loren ☺️</b></sub>](http://lorensr.me)<br />[📖](https://github.com/kentcdodds/react-testing-library/commits?author=lorensr "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/20678943?v=4" width="100px;" alt="MarkFalconbridge"/><br /><sub><b>MarkFalconbridge</b></sub>](https://github.com/MarkFalconbridge)<br />[🐛](https://github.com/kentcdodds/react-testing-library/issues?q=author%3AMarkFalconbridge "Bug reports") [💻](https://github.com/kentcdodds/react-testing-library/commits?author=MarkFalconbridge "Code") |
225225
<!-- ALL-CONTRIBUTORS-LIST:END -->
226226

227227
This project follows the [all-contributors][all-contributors] specification.

src/__tests__/render.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,16 @@ test('returns baseElement which defaults to document.body', () => {
5757

5858
it('cleansup document', () => {
5959
const spy = jest.fn()
60+
const divId = 'my-div';
6061

6162
class Test extends React.Component {
6263
componentWillUnmount() {
64+
expect(document.getElementById(divId)).toBeInTheDocument()
6365
spy()
6466
}
6567

6668
render() {
67-
return <div />
69+
return <div id={divId}/>
6870
}
6971
}
7072

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ function cleanup() {
7878
// maybe one day we'll expose this (perhaps even as a utility returned by render).
7979
// but let's wait until someone asks for it.
8080
function cleanupAtContainer(container) {
81+
ReactDOM.unmountComponentAtNode(container)
8182
if (container.parentNode === document.body) {
8283
document.body.removeChild(container)
8384
}
84-
ReactDOM.unmountComponentAtNode(container)
8585
mountedContainers.delete(container)
8686
}
8787

0 commit comments

Comments
 (0)