mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Make sure cloneElement() supports prototype-less config (#6878)
This brings createElement() fix from #6855 to cloneElement().
(cherry picked from commit e822cbd183)
This commit is contained in:
committed by
Paul O’Shannessy
parent
c8b2a3dc13
commit
31ba751d2e
@@ -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