* Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement
(type, config, children)
| 18119 | * See https://reactjs.org/docs/react-api.html#createelement |
| 18120 | */ |
| 18121 | function createElement(type, config, children) { |
| 18122 | var propName = void 0; |
| 18123 | |
| 18124 | // Reserved names are extracted |
| 18125 | var props = {}; |
| 18126 | |
| 18127 | var key = null; |
| 18128 | var ref = null; |
| 18129 | var self = null; |
| 18130 | var source = null; |
| 18131 | |
| 18132 | if (config != null) { |
| 18133 | if (hasValidRef(config)) { |
| 18134 | ref = config.ref; |
| 18135 | } |
| 18136 | if (hasValidKey(config)) { |
| 18137 | key = '' + config.key; |
| 18138 | } |
| 18139 | |
| 18140 | self = config.__self === undefined ? null : config.__self; |
| 18141 | source = config.__source === undefined ? null : config.__source; |
| 18142 | // Remaining properties are added to a new props object |
| 18143 | for (propName in config) { |
| 18144 | if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { |
| 18145 | props[propName] = config[propName]; |
| 18146 | } |
| 18147 | } |
| 18148 | } |
| 18149 | |
| 18150 | // Children can be more than one argument, and those are transferred onto |
| 18151 | // the newly allocated props object. |
| 18152 | var childrenLength = arguments.length - 2; |
| 18153 | if (childrenLength === 1) { |
| 18154 | props.children = children; |
| 18155 | } else if (childrenLength > 1) { |
| 18156 | var childArray = Array(childrenLength); |
| 18157 | for (var i = 0; i < childrenLength; i++) { |
| 18158 | childArray[i] = arguments[i + 2]; |
| 18159 | } |
| 18160 | { |
| 18161 | if (Object.freeze) { |
| 18162 | Object.freeze(childArray); |
| 18163 | } |
| 18164 | } |
| 18165 | props.children = childArray; |
| 18166 | } |
| 18167 | |
| 18168 | // Resolve default props |
| 18169 | if (type && type.defaultProps) { |
| 18170 | var defaultProps = type.defaultProps; |
| 18171 | for (propName in defaultProps) { |
| 18172 | if (props[propName] === undefined) { |
| 18173 | props[propName] = defaultProps[propName]; |
| 18174 | } |
| 18175 | } |
| 18176 | } |
| 18177 | { |
| 18178 | if (key || ref) { |
no test coverage detected