aboutsummaryrefslogtreecommitdiff
path: root/node_modules/react/lib/ReactFragment.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
commitde98e0b232509d5f40c135d540a70e415272ff85 (patch)
treea79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/react/lib/ReactFragment.js
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
node_modules
Diffstat (limited to 'node_modules/react/lib/ReactFragment.js')
-rw-r--r--node_modules/react/lib/ReactFragment.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/node_modules/react/lib/ReactFragment.js b/node_modules/react/lib/ReactFragment.js
new file mode 100644
index 000000000..b35ced2d4
--- /dev/null
+++ b/node_modules/react/lib/ReactFragment.js
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2015-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ */
+
+'use strict';
+
+var _prodInvariant = require('./reactProdInvariant');
+
+var ReactChildren = require('./ReactChildren');
+var ReactElement = require('./ReactElement');
+
+var emptyFunction = require('fbjs/lib/emptyFunction');
+var invariant = require('fbjs/lib/invariant');
+var warning = require('fbjs/lib/warning');
+
+/**
+ * We used to allow keyed objects to serve as a collection of ReactElements,
+ * or nested sets. This allowed us a way to explicitly key a set or fragment of
+ * components. This is now being replaced with an opaque data structure.
+ * The upgrade path is to call React.addons.createFragment({ key: value }) to
+ * create a keyed fragment. The resulting data structure is an array.
+ */
+
+var numericPropertyRegex = /^\d+$/;
+
+var warnedAboutNumeric = false;
+
+var ReactFragment = {
+ /**
+ * Wrap a keyed object in an opaque proxy that warns you if you access any
+ * of its properties.
+ * See https://facebook.github.io/react/docs/create-fragment.html
+ */
+ create: function (object) {
+ if (typeof object !== 'object' || !object || Array.isArray(object)) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment only accepts a single object. Got: %s', object) : void 0;
+ return object;
+ }
+ if (ReactElement.isValidElement(object)) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment does not accept a ReactElement ' + 'without a wrapper object.') : void 0;
+ return object;
+ }
+
+ !(object.nodeType !== 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.addons.createFragment(...): Encountered an invalid child; DOM elements are not valid children of React components.') : _prodInvariant('0') : void 0;
+
+ var result = [];
+
+ for (var key in object) {
+ if (process.env.NODE_ENV !== 'production') {
+ if (!warnedAboutNumeric && numericPropertyRegex.test(key)) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.addons.createFragment(...): Child objects should have ' + 'non-numeric keys so ordering is preserved.') : void 0;
+ warnedAboutNumeric = true;
+ }
+ }
+ ReactChildren.mapIntoWithKeyPrefixInternal(object[key], result, key, emptyFunction.thatReturnsArgument);
+ }
+
+ return result;
+ }
+};
+
+module.exports = ReactFragment; \ No newline at end of file