Skip to content

Commit

Permalink
Make sure cloneElement() supports prototype-less config (facebook#6878)
Browse files Browse the repository at this point in the history
This brings createElement() fix from facebook#6855 to cloneElement().
(cherry picked from commit e822cbd)
  • Loading branch information
gaearon authored and zpao committed Jun 8, 2016
1 parent 013f27b commit 2c4a03e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/isomorphic/classic/element/ReactElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ ReactElement.cloneElement = function(element, config, children) {
defaultProps = element.type.defaultProps;
}
for (propName in config) {
if (config.hasOwnProperty(propName) &&
if (hasOwnProperty.call(config, propName) &&
!RESERVED_PROPS.hasOwnProperty(propName)) {
if (config[propName] === undefined && defaultProps !== undefined) {
// Resolve default props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ describe('ReactElementClone', function() {
);
});

it('does not fail if config has no prototype', function() {
var config = Object.create(null, {foo: {value: 1, enumerable: true}});
React.cloneElement(<div />, config);
});

it('should keep the original ref if it is not overridden', function() {
var Grandparent = React.createClass({
render: function() {
Expand Down

0 comments on commit 2c4a03e

Please sign in to comment.