Debian Codegraph @

packages/babel-helpers/src/helpers/jsx.js

raw symbols SCIP
1 /* @minVersion 7.0.0-beta.0 */
2
3 var REACT_ELEMENT_TYPE;
4
5 export default function _createRawReactElement(type, props, key, children) {
6 if (!REACT_ELEMENT_TYPE) {
7 REACT_ELEMENT_TYPE =
8 (typeof Symbol === "function" &&
9 // "for" is a reserved keyword in ES3 so escaping it here for backward compatibility
10 Symbol["for"] &&
11 Symbol["for"]("react.element")) ||
12 0xeac7;
13 }
14
15 var defaultProps = type && type.defaultProps;
16 var childrenLength = arguments.length - 3;
17
18 if (!props && childrenLength !== 0) {
19 // If we're going to assign props.children, we create a new object now
20 // to avoid mutating defaultProps.
21 props = { children: void 0 };
22 }
23
24 if (childrenLength === 1) {
25 props.children = children;
26 } else if (childrenLength > 1) {
27 var childArray = new Array(childrenLength);
28 for (var i = 0; i < childrenLength; i++) {
29 childArray[i] = arguments[i + 3];
30 }
31 props.children = childArray;
32 }
33
34 if (props && defaultProps) {
35 for (var propName in defaultProps) {
36 if (props[propName] === void 0) {
37 props[propName] = defaultProps[propName];
38 }
39 }
40 } else if (!props) {
41 props = defaultProps || {};
42 }
43
44 return {
45 $$typeof: REACT_ELEMENT_TYPE,
46 type: type,
47 key: key === undefined ? null : "" + key,
48 ref: null,
49 props: props,
50 _owner: null,
51 };
52 }