Skip to content

Commit 6663fb3

Browse files
committed
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.
1 parent b4ee5b5 commit 6663fb3

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/isomorphic/classic/element/ReactElement.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ var ReactElement = function(type, key, ref, self, source, owner, props) {
8181

8282
// We intentionally don't expose the function on the constructor property.
8383
// ReactElement should be indistinguishable from a plain object.
84-
ReactElement.prototype = {
85-
_isReactElement: true,
86-
};
84+
ReactElement.prototype = {};
8785

8886
ReactElement.createElement = function(type, config, children) {
8987
var propName;
@@ -251,17 +249,12 @@ ReactElement.cloneElement = function(element, config, children) {
251249
* @final
252250
*/
253251
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+
);
265258
};
266259

267260
module.exports = ReactElement;

src/renderers/dom/client/ReactMount.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,8 @@ var ReactMount = {
976976

977977
getNodeFromInstance: getNodeFromInstance,
978978

979+
isValid: isValid,
980+
979981
purgeID: purgeID,
980982
};
981983

0 commit comments

Comments
 (0)