File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -44,12 +44,19 @@ describe('findDOMNode', function() {
44
44
} ) ;
45
45
46
46
it ( 'findDOMNode should reject unmounted objects with render func' , function ( ) {
47
- expect ( function ( ) {
48
- ReactDOM . findDOMNode ( { render : function ( ) { } } ) ;
49
- } )
50
- . toThrow ( 'Invariant Violation: Component (with keys: render) ' +
51
- 'contains `render` method but is not mounted in the DOM'
52
- ) ;
47
+ var Foo = React . createClass ( {
48
+ render : function ( ) {
49
+ return < div /> ;
50
+ } ,
51
+ } ) ;
52
+
53
+ var container = document . createElement ( 'div' ) ;
54
+ var inst = ReactDOM . render ( < Foo /> , container ) ;
55
+ ReactDOM . unmountComponentAtNode ( container ) ;
56
+
57
+ expect ( ( ) => ReactDOM . findDOMNode ( inst ) ) . toThrow (
58
+ 'Invariant Violation: findDOMNode was called on an unmounted component.'
59
+ ) ;
53
60
} ) ;
54
61
55
62
} ) ;
Original file line number Diff line number Diff line change @@ -53,9 +53,7 @@ function findDOMNode(componentOrElement) {
53
53
invariant (
54
54
componentOrElement . render == null ||
55
55
typeof componentOrElement . render !== 'function' ,
56
- 'Component (with keys: %s) contains `render` method ' +
57
- 'but is not mounted in the DOM' ,
58
- Object . keys ( componentOrElement )
56
+ 'findDOMNode was called on an unmounted component.'
59
57
) ;
60
58
invariant (
61
59
false ,
You can’t perform that action at this time.
0 commit comments