From 6663fb3135f341b03b1342108bf26da34d90a6fb Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Tue, 18 Aug 2015 12:55:34 -0700 Subject: [PATCH] Remove _isReactElement As of this commit, we still support objects as maps so if anyone has an object with keys 'type' and 'props' this will change behavior, but otherwise this should be pretty safe. --- .../classic/element/ReactElement.js | 21 +++++++------------ src/renderers/dom/client/ReactMount.js | 2 ++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/isomorphic/classic/element/ReactElement.js b/src/isomorphic/classic/element/ReactElement.js index 62f7f8e49f1b..ecf60bee77a0 100644 --- a/src/isomorphic/classic/element/ReactElement.js +++ b/src/isomorphic/classic/element/ReactElement.js @@ -81,9 +81,7 @@ var ReactElement = function(type, key, ref, self, source, owner, props) { // We intentionally don't expose the function on the constructor property. // ReactElement should be indistinguishable from a plain object. -ReactElement.prototype = { - _isReactElement: true, -}; +ReactElement.prototype = {}; ReactElement.createElement = function(type, config, children) { var propName; @@ -251,17 +249,12 @@ ReactElement.cloneElement = function(element, config, children) { * @final */ ReactElement.isValidElement = function(object) { - // ReactTestUtils is often used outside of beforeEach where as React is - // within it. This leads to two different instances of React on the same - // page. To identify a element from a different React instance we use - // a flag instead of an instanceof check. - var isElement = !!(object && object._isReactElement); - // if (isElement && !(object instanceof ReactElement)) { - // This is an indicator that you're using multiple versions of React at the - // same time. This will screw with ownership and stuff. Fix it, please. - // TODO: We could possibly warn here. - // } - return isElement; + return !!( + typeof object === 'object' && + object != null && + 'type' in object && + 'props' in object + ); }; module.exports = ReactElement; diff --git a/src/renderers/dom/client/ReactMount.js b/src/renderers/dom/client/ReactMount.js index c505d0dd67cb..aeb386840ff9 100644 --- a/src/renderers/dom/client/ReactMount.js +++ b/src/renderers/dom/client/ReactMount.js @@ -976,6 +976,8 @@ var ReactMount = { getNodeFromInstance: getNodeFromInstance, + isValid: isValid, + purgeID: purgeID, };