diff --git a/src/renderers/dom/client/ReactMount.js b/src/renderers/dom/client/ReactMount.js index 875ec61408..899eb879fa 100644 --- a/src/renderers/dom/client/ReactMount.js +++ b/src/renderers/dom/client/ReactMount.js @@ -392,12 +392,11 @@ function findFirstReactDOMImpl(node) { do { lastID = internalGetID(current); current = current.parentNode; - invariant( - current != null, - 'findFirstReactDOMImpl(...): Unexpected detached subtree found when ' + - 'traversing DOM from node `%s`.', - nodeID - ); + if (current == null) { + // The passed-in node has been detached from the container it was + // originally rendered into. + return null; + } } while (lastID !== reactRootID); if (current === containersByReactRootID[reactRootID]) { diff --git a/src/renderers/dom/client/__tests__/ReactEventIndependence-test.js b/src/renderers/dom/client/__tests__/ReactEventIndependence-test.js new file mode 100644 index 0000000000..621118cfd4 --- /dev/null +++ b/src/renderers/dom/client/__tests__/ReactEventIndependence-test.js @@ -0,0 +1,70 @@ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @emails react-core + */ + +'use strict'; + +var React; +var ReactDOM; +var ReactTestUtils; + +describe('ReactEventIndependence', function() { + beforeEach(function() { + require('mock-modules').dumpCache(); + + React = require('React'); + ReactDOM = require('ReactDOM'); + ReactTestUtils = require('ReactTestUtils'); + }); + + it('does not crash with other react inside', function() { + var clicks = 0; + var div = ReactTestUtils.renderIntoDocument( +