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.
Ben Alpert committed
Aug 18, 2015 at 12:55 UTC
6663fb3135f341b03b1342108bf26da34d90a6fb
2 files changed
+9
-14
src/isomorphic/classic/element/ReactElement.js
+7
-14
@@ -81,9 +81,7 @@ var ReactElement = function(type, key, ref, self, source, owner, props) {
81
82
// We intentionally don't expose the function on the constructor property.
83
// ReactElement should be indistinguishable from a plain object.
84
-ReactElement.prototype = {
85
- _isReactElement: true,
86
-};
84
+ReactElement.prototype = {};
85
86
ReactElement.createElement = function(type, config, children) {
87
var propName;
@@ -251,17 +249,12 @@ ReactElement.cloneElement = function(element, config, children) {
249
* @final
250
*/
251
ReactElement.isValidElement = function(object) {
254
- // ReactTestUtils is often used outside of beforeEach where as React is
255
- // within it. This leads to two different instances of React on the same
256
- // page. To identify a element from a different React instance we use
257
- // a flag instead of an instanceof check.
258
- var isElement = !!(object && object._isReactElement);
259
- // if (isElement && !(object instanceof ReactElement)) {
260
- // This is an indicator that you're using multiple versions of React at the
261
- // same time. This will screw with ownership and stuff. Fix it, please.
262
- // TODO: We could possibly warn here.
263
- // }
264
- return isElement;
252
+ return !!(
253
+ typeof object === 'object' &&
254
+ object != null &&
255
+ 'type' in object &&
256
+ 'props' in object
257
+ );
258
};
259
260
module.exports = ReactElement;
src/renderers/dom/client/ReactMount.js
+2
@@ -976,6 +976,8 @@ var ReactMount = {
976
977
getNodeFromInstance: getNodeFromInstance,
978
979
+ isValid: isValid,
980
+
981
purgeID: purgeID,
982
};
983