@samitouri / QOS-React-2 / commits / 7e5ce19a94

Fix diverging behavior of ReactFragment in `__DEV__`

We could also remove the return statements but this is not a hot path and this seems safer.

Ben Alpert committed Sep 1, 2015 at 13:07 UTC 7e5ce19a94a3b113db7be1361b5d009126c64e0a
1 file changed +16 -17
src/addons/ReactFragment.js
+16 -17
@@ -46,24 +46,23 @@ var ReactFragment = {
46 // Wrap a keyed object in an opaque proxy that warns you if you access any
47 // of its properties.
48 create: function(object) {
49 - if (__DEV__) {
50 - if (typeof object !== 'object' || !object || Array.isArray(object)) {
51 - warning(
52 - false,
53 - 'React.addons.createFragment only accepts a single object. Got: %s',
54 - object
55 - );
56 - return object;
57 - }
58 - if (ReactElement.isValidElement(object)) {
59 - warning(
60 - false,
61 - 'React.addons.createFragment does not accept a ReactElement ' +
62 - 'without a wrapper object.'
63 - );
64 - return object;
65 - }
49 + if (typeof object !== 'object' || !object || Array.isArray(object)) {
50 + warning(
51 + false,
52 + 'React.addons.createFragment only accepts a single object. Got: %s',
53 + object
54 + );
55 + return object;
56 }
57 + if (ReactElement.isValidElement(object)) {
58 + warning(
59 + false,
60 + 'React.addons.createFragment does not accept a ReactElement ' +
61 + 'without a wrapper object.'
62 + );
63 + return object;
64 + }
65 +
66 invariant(
67 object.nodeType !== 1,
68 'React.addons.createFragment(...): Encountered an invalid child; DOM ' +