* Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement
(type, config, children)
| 18028 | * See https://reactjs.org/docs/react-api.html#createelement |
| 18029 | */ |
| 18030 | function createElement(type, config, children) { |
| 18031 | var propName = void 0; |
| 18032 | |
| 18033 | // Reserved names are extracted |
| 18034 | var props = {}; |
| 18035 | |
| 18036 | var key = null; |
| 18037 | var ref = null; |
| 18038 | var self = null; |
| 18039 | var source = null; |
| 18040 | |
| 18041 | if (config != null) { |
| 18042 | if (hasValidRef(config)) { |
| 18043 | ref = config.ref; |
| 18044 | } |
| 18045 | if (hasValidKey(config)) { |
| 18046 | key = '' + config.key; |
| 18047 | } |
| 18048 | |
| 18049 | self = config.__self === undefined ? null : config.__self; |
| 18050 | source = config.__source === undefined ? null : config.__source; |
| 18051 | // Remaining properties are added to a new props object |
| 18052 | for (propName in config) { |
| 18053 | if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { |
| 18054 | props[propName] = config[propName]; |
| 18055 | } |
| 18056 | } |
| 18057 | } |
| 18058 | |
| 18059 | // Children can be more than one argument, and those are transferred onto |
| 18060 | // the newly allocated props object. |
| 18061 | var childrenLength = arguments.length - 2; |
| 18062 | if (childrenLength === 1) { |
| 18063 | props.children = children; |
| 18064 | } else if (childrenLength > 1) { |
| 18065 | var childArray = Array(childrenLength); |
| 18066 | for (var i = 0; i < childrenLength; i++) { |
| 18067 | childArray[i] = arguments[i + 2]; |
| 18068 | } |
| 18069 | { |
| 18070 | if (Object.freeze) { |
| 18071 | Object.freeze(childArray); |
| 18072 | } |
| 18073 | } |
| 18074 | props.children = childArray; |
| 18075 | } |
| 18076 | |
| 18077 | // Resolve default props |
| 18078 | if (type && type.defaultProps) { |
| 18079 | var defaultProps = type.defaultProps; |
| 18080 | for (propName in defaultProps) { |
| 18081 | if (props[propName] === undefined) { |
| 18082 | props[propName] = defaultProps[propName]; |
| 18083 | } |
| 18084 | } |
| 18085 | } |
| 18086 | { |
| 18087 | if (key || ref) { |
no test coverage detected