* Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement
(type, config, children)
| 18789 | * See https://reactjs.org/docs/react-api.html#createelement |
| 18790 | */ |
| 18791 | function createElement(type, config, children) { |
| 18792 | var propName = void 0; |
| 18793 | |
| 18794 | // Reserved names are extracted |
| 18795 | var props = {}; |
| 18796 | |
| 18797 | var key = null; |
| 18798 | var ref = null; |
| 18799 | var self = null; |
| 18800 | var source = null; |
| 18801 | |
| 18802 | if (config != null) { |
| 18803 | if (hasValidRef(config)) { |
| 18804 | ref = config.ref; |
| 18805 | } |
| 18806 | if (hasValidKey(config)) { |
| 18807 | key = '' + config.key; |
| 18808 | } |
| 18809 | |
| 18810 | self = config.__self === undefined ? null : config.__self; |
| 18811 | source = config.__source === undefined ? null : config.__source; |
| 18812 | // Remaining properties are added to a new props object |
| 18813 | for (propName in config) { |
| 18814 | if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { |
| 18815 | props[propName] = config[propName]; |
| 18816 | } |
| 18817 | } |
| 18818 | } |
| 18819 | |
| 18820 | // Children can be more than one argument, and those are transferred onto |
| 18821 | // the newly allocated props object. |
| 18822 | var childrenLength = arguments.length - 2; |
| 18823 | if (childrenLength === 1) { |
| 18824 | props.children = children; |
| 18825 | } else if (childrenLength > 1) { |
| 18826 | var childArray = Array(childrenLength); |
| 18827 | for (var i = 0; i < childrenLength; i++) { |
| 18828 | childArray[i] = arguments[i + 2]; |
| 18829 | } |
| 18830 | { |
| 18831 | if (Object.freeze) { |
| 18832 | Object.freeze(childArray); |
| 18833 | } |
| 18834 | } |
| 18835 | props.children = childArray; |
| 18836 | } |
| 18837 | |
| 18838 | // Resolve default props |
| 18839 | if (type && type.defaultProps) { |
| 18840 | var defaultProps = type.defaultProps; |
| 18841 | for (propName in defaultProps) { |
| 18842 | if (props[propName] === undefined) { |
| 18843 | props[propName] = defaultProps[propName]; |
| 18844 | } |
| 18845 | } |
| 18846 | } |
| 18847 | { |
| 18848 | if (key || ref) { |
no test coverage detected