UNPKG

1.14 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 (childrenLength === 1) {
18 props.children = children;
19 } else if (childrenLength > 1) {
20 var childArray = new Array(childrenLength);
21
22 for (var i = 0; i < childrenLength; i++) {
23 childArray[i] = arguments[i + 3];
24 }
25
26 props.children = childArray;
27 }
28
29 if (props && defaultProps) {
30 for (var propName in defaultProps) {
31 if (props[propName] === void 0) {
32 props[propName] = defaultProps[propName];
33 }
34 }
35 } else if (!props) {
36 props = defaultProps || {};
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