Error when unmountComponentAtNode receives non-node
Justin Woo committed
Aug 24, 2014 at 10:53 UTC
9c8ddb33169d47374df45f6672acf6ef154da968
2 files changed
+20
src/browser/ui/ReactMount.js
+8
@@ -465,6 +465,14 @@ var ReactMount = {
465
'componentDidUpdate.'
466
);
467
468
+ invariant(
469
+ container && (
470
+ container.nodeType === ELEMENT_NODE_TYPE ||
471
+ container.nodeType === DOC_NODE_TYPE
472
+ ),
473
+ 'unmountComponentAtNode(...): Target container is not a DOM element.'
474
+ );
475
+
476
var reactRootID = getReactRootID(container);
477
var component = instancesByReactRootID[reactRootID];
478
if (!component) {
src/browser/ui/__tests__/ReactMount-test.js
+12
@@ -38,6 +38,18 @@ describe('ReactMount', function() {
38
});
39
});
40
41
+ describe('unmountComponentAtNode', function() {
42
+ it('throws when given a non-node', function() {
43
+ var nodeArray = document.getElementsByTagName('div');
44
+ expect(function() {
45
+ React.unmountComponentAtNode(nodeArray);
46
+ }).toThrow(
47
+ 'Invariant Violation: unmountComponentAtNode(...): Target container ' +
48
+ 'is not a DOM element.'
49
+ );
50
+ });
51
+ });
52
+
53
it('throws when given a string', function() {
54
expect(function() {
55
ReactTestUtils.renderIntoDocument('div');