* Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement
(type, config, children)
| 1117 | */ |
| 1118 | |
| 1119 | function createElement(type, config, children) { |
| 1120 | var propName; // Reserved names are extracted |
| 1121 | |
| 1122 | var props = {}; |
| 1123 | var key = null; |
| 1124 | var ref = null; |
| 1125 | var self = null; |
| 1126 | var source = null; |
| 1127 | |
| 1128 | if (config != null) { |
| 1129 | if (hasValidRef(config)) { |
| 1130 | ref = config.ref; |
| 1131 | |
| 1132 | { |
| 1133 | warnIfStringRefCannotBeAutoConverted(config); |
| 1134 | } |
| 1135 | } |
| 1136 | |
| 1137 | if (hasValidKey(config)) { |
| 1138 | key = '' + config.key; |
| 1139 | } |
| 1140 | |
| 1141 | self = config.__self === undefined ? null : config.__self; |
| 1142 | source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object |
| 1143 | |
| 1144 | for (propName in config) { |
| 1145 | if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { |
| 1146 | props[propName] = config[propName]; |
| 1147 | } |
| 1148 | } |
| 1149 | } // Children can be more than one argument, and those are transferred onto |
| 1150 | // the newly allocated props object. |
| 1151 | |
| 1152 | |
| 1153 | var childrenLength = arguments.length - 2; |
| 1154 | |
| 1155 | if (childrenLength === 1) { |
| 1156 | props.children = children; |
| 1157 | } else if (childrenLength > 1) { |
| 1158 | var childArray = Array(childrenLength); |
| 1159 | |
| 1160 | for (var i = 0; i < childrenLength; i++) { |
| 1161 | childArray[i] = arguments[i + 2]; |
| 1162 | } |
| 1163 | |
| 1164 | { |
| 1165 | if (Object.freeze) { |
| 1166 | Object.freeze(childArray); |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | props.children = childArray; |
| 1171 | } // Resolve default props |
| 1172 | |
| 1173 | |
| 1174 | if (type && type.defaultProps) { |
| 1175 | var defaultProps = type.defaultProps; |
| 1176 |
no test coverage detected