mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Fix return value of ReactDOMFiber.unmountComponentAtNode (#9619)
This commit is contained in:
@@ -1240,6 +1240,8 @@ src/renderers/dom/shared/__tests__/ReactEventListener-test.js
|
||||
|
||||
src/renderers/dom/shared/__tests__/ReactMount-test.js
|
||||
* throws when given a non-node
|
||||
* returns false on non-React containers
|
||||
* returns true on React containers
|
||||
* throws when given a string
|
||||
* throws when given a factory
|
||||
* should render different components in same root
|
||||
|
||||
@@ -518,11 +518,16 @@ var ReactDOM = {
|
||||
}
|
||||
|
||||
// Unmount should not be batched.
|
||||
return DOMRenderer.unbatchedUpdates(() => {
|
||||
return renderSubtreeIntoContainer(null, null, container, () => {
|
||||
DOMRenderer.unbatchedUpdates(() => {
|
||||
renderSubtreeIntoContainer(null, null, container, () => {
|
||||
container._reactRootContainer = null;
|
||||
});
|
||||
});
|
||||
// If you call unmountComponentAtNode twice in quick succession, you'll
|
||||
// get `true` twice. That's probably fine?
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -46,6 +46,21 @@ describe('ReactMount', () => {
|
||||
'unmountComponentAtNode(...): Target container is not a DOM element.',
|
||||
);
|
||||
});
|
||||
|
||||
it('returns false on non-React containers', () => {
|
||||
var d = document.createElement('div');
|
||||
d.innerHTML = '<b>hellooo</b>';
|
||||
expect(ReactDOM.unmountComponentAtNode(d)).toBe(false);
|
||||
expect(d.textContent).toBe('hellooo');
|
||||
});
|
||||
|
||||
it('returns true on React containers', () => {
|
||||
var d = document.createElement('div');
|
||||
ReactDOM.render(<b>hellooo</b>, d);
|
||||
expect(d.textContent).toBe('hellooo');
|
||||
expect(ReactDOM.unmountComponentAtNode(d)).toBe(true);
|
||||
expect(d.textContent).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
it('throws when given a string', () => {
|
||||
|
||||
Reference in New Issue
Block a user