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