mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Make sure cloneElement() supports prototype-less config (#6878)
This brings createElement() fix from #6855 to cloneElement().
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user