UNPKG

1.13 kBJavaScriptView Raw
1var REACT_ELEMENT_TYPE;
2
3function _createRawReactElement(type, props, key, children) {
4 if (!REACT_ELEMENT_TYPE) {
5 REACT_ELEMENT_TYPE = typeof Symbol === "function" && Symbol.for && Symbol.for("react.element") || 0xeac7;
6 }
7
8 var defaultProps = type && type.defaultProps;
9 var childrenLength = arguments.length - 3;
10
11 if (!props && childrenLength !== 0) {
12 props = {
13 children: void 0
14 };
15 }
16
17 if (props && defaultProps) {
18 for (var propName in defaultProps) {
19 if (props[propName] === void 0) {
20 props[propName] = defaultProps[propName];
21 }
22 }
23 } else if (!props) {
24 props = defaultProps || {};
25 }
26
27 if (childrenLength === 1) {
28 props.children = children;
29 } else if (childrenLength > 1) {
30 var childArray = new Array(childrenLength);
31
32 for (var i = 0; i < childrenLength; i++) {
33 childArray[i] = arguments[i + 3];
34 }
35
36 props.children = childArray;
37 }
38
39 return {
40 $$typeof: REACT_ELEMENT_TYPE,
41 type: type,
42 key: key === undefined ? null : '' + key,
43 ref: null,
44 props: props,
45 _owner: null
46 };
47}
48
49module.exports = _createRawReactElement;
\No newline at end of file