@@ -22,7 +22,6 @@ var invariant = require('invariant');
2222var keyMirror = require ( 'keyMirror' ) ;
2323var keyOf = require ( 'keyOf' ) ;
2424var monitorCodeUse = require ( 'monitorCodeUse' ) ;
25- var mapObject = require ( 'mapObject' ) ;
2625var warning = require ( 'warning' ) ;
2726
2827var MIXINS_KEY = keyOf ( { mixins : null } ) ;
@@ -566,24 +565,26 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
566565 * @param {object } two The second object
567566 * @return {object } one after it has been mutated to contain everything in two.
568567 */
569- function mergeObjectsWithNoDuplicateKeys ( one , two ) {
568+ function mergeIntoWithNoDuplicateKeys ( one , two ) {
570569 invariant (
571570 one && two && typeof one === 'object' && typeof two === 'object' ,
572- 'mergeObjectsWithNoDuplicateKeys (): Cannot merge non-objects'
571+ 'mergeIntoWithNoDuplicateKeys (): Cannot merge non-objects. '
573572 ) ;
574573
575- mapObject ( two , function ( value , key ) {
576- invariant (
577- one [ key ] === undefined ,
578- 'mergeObjectsWithNoDuplicateKeys(): ' +
579- 'Tried to merge two objects with the same key: `%s`. This conflict ' +
580- 'may be due to a mixin; in particular, this may be caused by two ' +
581- 'getInitialState() or getDefaultProps() methods returning objects ' +
582- 'with clashing keys.' ,
583- key
584- ) ;
585- one [ key ] = value ;
586- } ) ;
574+ for ( var key in two ) {
575+ if ( two . hasOwnProperty ( key ) ) {
576+ invariant (
577+ one [ key ] === undefined ,
578+ 'mergeIntoWithNoDuplicateKeys(): ' +
579+ 'Tried to merge two objects with the same key: `%s`. This conflict ' +
580+ 'may be due to a mixin; in particular, this may be caused by two ' +
581+ 'getInitialState() or getDefaultProps() methods returning objects ' +
582+ 'with clashing keys.' ,
583+ key
584+ ) ;
585+ one [ key ] = two [ key ] ;
586+ }
587+ }
587588 return one ;
588589}
589590
@@ -604,7 +605,10 @@ function createMergedResultFunction(one, two) {
604605 } else if ( b == null ) {
605606 return a ;
606607 }
607- return mergeObjectsWithNoDuplicateKeys ( a , b ) ;
608+ var c = { } ;
609+ mergeIntoWithNoDuplicateKeys ( c , a ) ;
610+ mergeIntoWithNoDuplicateKeys ( c , b ) ;
611+ return c ;
608612 } ;
609613}
610614
0 commit comments