File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1+ // this is where we'll put bug reproductions/regressions
2+ // to make sure we never see them again
3+
4+ import React from 'react'
5+ import { render , cleanup } from '../'
6+
7+ test ( 'cleanup does not error when an element is not a child' , ( ) => {
8+ render ( < div /> , { container : document . createElement ( 'div' ) } )
9+ cleanup ( )
10+ } )
Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ function cleanup() {
3737// maybe one day we'll expose this (perhaps even as a utility returned by render).
3838// but let's wait until someone asks for it.
3939function cleanupAtContainer ( container ) {
40- document . body . removeChild ( container )
40+ if ( container . parentNode === document . body ) {
41+ document . body . removeChild ( container )
42+ }
4143 ReactDOM . unmountComponentAtNode ( container )
4244 mountedContainers . delete ( container )
4345}
You can’t perform that action at this time.
0 commit comments