Make sure cloneElement() supports prototype-less config (#6878)
This brings createElement() fix from #6855 to cloneElement().
Dan Abramov committed
May 26, 2016 at 00:37 UTC
e822cbd183bb6e531068ab8d3be1e1e79c632877
2 files changed
+6
-1
src/isomorphic/classic/element/ReactElement.js
+1
-1
@@ -311,7 +311,7 @@ ReactElement.cloneElement = function(element, config, children) {
311
defaultProps = element.type.defaultProps;
312
}
313
for (propName in config) {
314
- if (config.hasOwnProperty(propName) &&
314
+ if (hasOwnProperty.call(config, propName) &&
315
!RESERVED_PROPS.hasOwnProperty(propName)) {
316
if (config[propName] === undefined && defaultProps !== undefined) {
317
// Resolve default props
src/isomorphic/classic/element/__tests__/ReactElementClone-test.js
+5
@@ -78,6 +78,11 @@ describe('ReactElementClone', function() {
78
);
79
});
80
81
+ it('does not fail if config has no prototype', function() {
82
+ var config = Object.create(null, {foo: {value: 1, enumerable: true}});
83
+ React.cloneElement(<div />, config);
84
+ });
85
+
86
it('should keep the original ref if it is not overridden', function() {
87
var Grandparent = React.createClass({
88
render: function() {