* Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement
(type, config, children)
| 18888 | * See https://reactjs.org/docs/react-api.html#createelement |
| 18889 | */ |
| 18890 | function createElement(type, config, children) { |
| 18891 | var propName = void 0; |
| 18892 | |
| 18893 | // Reserved names are extracted |
| 18894 | var props = {}; |
| 18895 | |
| 18896 | var key = null; |
| 18897 | var ref = null; |
| 18898 | var self = null; |
| 18899 | var source = null; |
| 18900 | |
| 18901 | if (config != null) { |
| 18902 | if (hasValidRef(config)) { |
| 18903 | ref = config.ref; |
| 18904 | } |
| 18905 | if (hasValidKey(config)) { |
| 18906 | key = '' + config.key; |
| 18907 | } |
| 18908 | |
| 18909 | self = config.__self === undefined ? null : config.__self; |
| 18910 | source = config.__source === undefined ? null : config.__source; |
| 18911 | // Remaining properties are added to a new props object |
| 18912 | for (propName in config) { |
| 18913 | if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { |
| 18914 | props[propName] = config[propName]; |
| 18915 | } |
| 18916 | } |
| 18917 | } |
| 18918 | |
| 18919 | // Children can be more than one argument, and those are transferred onto |
| 18920 | // the newly allocated props object. |
| 18921 | var childrenLength = arguments.length - 2; |
| 18922 | if (childrenLength === 1) { |
| 18923 | props.children = children; |
| 18924 | } else if (childrenLength > 1) { |
| 18925 | var childArray = Array(childrenLength); |
| 18926 | for (var i = 0; i < childrenLength; i++) { |
| 18927 | childArray[i] = arguments[i + 2]; |
| 18928 | } |
| 18929 | { |
| 18930 | if (Object.freeze) { |
| 18931 | Object.freeze(childArray); |
| 18932 | } |
| 18933 | } |
| 18934 | props.children = childArray; |
| 18935 | } |
| 18936 | |
| 18937 | // Resolve default props |
| 18938 | if (type && type.defaultProps) { |
| 18939 | var defaultProps = type.defaultProps; |
| 18940 | for (propName in defaultProps) { |
| 18941 | if (props[propName] === undefined) { |
| 18942 | props[propName] = defaultProps[propName]; |
| 18943 | } |
| 18944 | } |
| 18945 | } |
| 18946 | { |
| 18947 | if (key || ref) { |
no test coverage detected