( type: ElementType, config: any, ...maybeChildren: any )
| 36 | } |
| 37 | |
| 38 | export const createElement = ( |
| 39 | type: ElementType, |
| 40 | config: any, |
| 41 | ...maybeChildren: any |
| 42 | ) => { |
| 43 | let key: Key = null; |
| 44 | const props: Props = {}; |
| 45 | let ref: Ref = null; |
| 46 | |
| 47 | for (const prop in config) { |
| 48 | const val = config[prop]; |
| 49 | if (prop === 'key') { |
| 50 | if (val !== undefined) { |
| 51 | key = '' + val; |
| 52 | } |
| 53 | continue; |
| 54 | } |
| 55 | if (prop === 'ref') { |
| 56 | if (val !== undefined) { |
| 57 | ref = val; |
| 58 | } |
| 59 | continue; |
| 60 | } |
| 61 | if ({}.hasOwnProperty.call(config, prop)) { |
| 62 | props[prop] = val; |
| 63 | } |
| 64 | } |
| 65 | const maybeChildrenLength = maybeChildren.length; |
| 66 | if (maybeChildrenLength) { |
| 67 | if (maybeChildrenLength === 1) { |
| 68 | props.children = maybeChildren[0]; |
| 69 | } else { |
| 70 | props.children = maybeChildren; |
| 71 | } |
| 72 | } |
| 73 | return ReactElement(type, key, ref, props); |
| 74 | }; |
| 75 | |
| 76 | export const Fragment = REACT_FRAGMENT_TYPE; |
| 77 |
nothing calls this directly
no test coverage detected