Merge pull request #2405 from sebmarkbage/hideelementconstructor

Hide ReactElement constructor
This commit is contained in:
Sebastian Markbåge committed 2014-10-23 12:06:16 -07:00
commit 4aee2a9c28
2 files changed
+12 -2

No files matched your search

+6 -2
View File
@@ -120,12 +120,16 @@ var ReactElement = function(type, key, ref, owner, context, props) {
this.props = props;
};
// We intentionally don't expose the function on the constructor property.
// ReactElement should be indistinguishable from a plain object.
ReactElement.prototype = {
_isReactElement: true
};
if (__DEV__) {
defineMutationMembrane(ReactElement.prototype);
}
ReactElement.prototype._isReactElement = true;
ReactElement.createElement = function(type, config, children) {
var propName;
+6
View File
@@ -311,4 +311,10 @@ describe('ReactElement', function() {
expect(instance.getDOMNode().tagName).toBe('DIV');
});
it('is indistinguishable from a plain object', function() {
var element = React.createElement('div', { className: 'foo' });
var object = {};
expect(element.constructor).toBe(object.constructor);
});
});