mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Error when unmountComponentAtNode receives non-node
This commit is contained in:
@@ -465,6 +465,14 @@ var ReactMount = {
|
||||
'componentDidUpdate.'
|
||||
);
|
||||
|
||||
invariant(
|
||||
container && (
|
||||
container.nodeType === ELEMENT_NODE_TYPE ||
|
||||
container.nodeType === DOC_NODE_TYPE
|
||||
),
|
||||
'unmountComponentAtNode(...): Target container is not a DOM element.'
|
||||
);
|
||||
|
||||
var reactRootID = getReactRootID(container);
|
||||
var component = instancesByReactRootID[reactRootID];
|
||||
if (!component) {
|
||||
|
||||
@@ -38,6 +38,18 @@ describe('ReactMount', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('unmountComponentAtNode', function() {
|
||||
it('throws when given a non-node', function() {
|
||||
var nodeArray = document.getElementsByTagName('div');
|
||||
expect(function() {
|
||||
React.unmountComponentAtNode(nodeArray);
|
||||
}).toThrow(
|
||||
'Invariant Violation: unmountComponentAtNode(...): Target container ' +
|
||||
'is not a DOM element.'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('throws when given a string', function() {
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument('div');
|
||||
|
||||
Reference in New Issue
Block a user